Results 1 to 2 of 2

Thread: Sending OSQL command to command prompt

  1. #1
    Junior Member
    Join Date
    Jan 07
    Posts
    17

    Sending OSQL command to command prompt

    Hi all,

    I have two major problems about running OSQL from my c# code, first is running .sql commands using -i parameter with long and blank containing file locations and the second is passing the right command format to command prompt.

    1- When I type a command like
    Code:
    osql -U test -P testpass -S PROJETEST -i C:\testsql.sql
    osql works fine.

    But when I change it to sth like


    Code:
    osql -U test -P testpass -S PROJETEST -i C:\Users\ceyhun.ganioglu\Documents\Visual Studio 2008\Projects\TestProjectLoader\TestProjectLoader\bin\Debug\sqlscripts\2008_r2\testsql.sql
    I get an error like "osql does not support all features of SQL Server 2008 R2." Adding the " at the beginning and end of the file location did not work.


    2- I have the following code in my C# code. Does not matter if I get the directory dynamically or just type C:\\testsql.sql after -i parameter, I get the same error.
    Code:
    string mevcut_adres = Directory.GetCurrentDirectory();
    Process.Start("cmd.exe", "/K osql -U " + kullanici_adi.Text + " -P " + kullanici_sifre.Text + " -S " + sql_server_list.Text + "-i " + mevcut_adres + "\\sqlscripts\\2008_r2\\test.sql");
    I could not make it work at all. Can anybody help?

    Many thanks

  2. #2
    Lively Member
    Join Date
    Oct 08
    Location
    Califorina
    Posts
    126

    Re: Sending OSQL command to command prompt

    use sqlcmd for sql2005 and higher.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •