Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Saturday, February 25, 2012

osql

i'm trying to execute some scripts created by the express studio script wizard. i can connect with the studio, the website (asp worker) but i can't create the right cmdline for osql ..... this is my osql line ......

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn>osql -S (local)\\SQLEXPRESS -U sa -P sablah -i run.sql.......

this is the error i'm getting in my logs

Error: 18456, Severity: 14, State: 16.
2006-12-22 15:30:45.11 Logon Login failed for user 'sa'. [CLIENT: <local machine>]

"Server=(local)\\SQLEXPRESS;Database=ggmi;User Id=sa;Password=cr79cr02;Trusted_connection=false;";

the following is the working connection string for my aspworker.

"Server=(local)\\SQLEXPRESS;Database=ggmi;User Id=sa;Password=cr79cr02;Trusted_connection=false;";

when i try to put in the trust conenction parameter is says that it conflicts with the user flag ,. probably because its a differant type of login process. any ideas?

First, you only use EITHER username/password OR Trusted_Connection -NOT both. So the second connection string should fail.

Second, in the connection string, the server 'should' have only one [\] between the machinename and the instancename.

|||Yah, i believe i posted that. for asp.net the string actually works. i know why its not supposed to be there. and thats obivously why i can't add that argument to the osql statement. but i'm still left with the original posting of my error. i'm not missing anything in my osql statement?|||

Reading your post again, it seems that you indicated that your ASP connection string failed.

is98 wrote:

the following is the working connection string for my aspworker.

"Server=(local)\\SQLEXPRESS;Database=ggmi;User Id=sa;Password=cr79cr02;Trusted_connection=false;";

when i try to put in the trust conenction parameter is says that it conflicts with the user flag ,. probably because its a differant type of login process. any ideas?

ASP may be able to handle the two backslashes in the servername, but OSQL cannot. And if I recall, doesn't ASP use (localhost) instead of (local)?

Try: "server=(local)\SQLExpress" INSTEAD OF "Server=(local)\\SQLEXPRESS"

|||who the man? you the man. the localhost part works still ok. i just took out the extra slash which obiviously now explains why it couldn't find the server. thanks muchly.|||

The double back-slash is an escape character for C based languages, such as C#. When ever you want to pass a backslash in a C based language, you either need to use the "\\" escape sequence or use the @. to indicate a litteral string. You are passing literal strings to oSQL, not C#, so the "\\" is not needed, as you've found.

Just thought you'd be interested in understanding that this wasn't just random behaivor.

Mike