January 25, 2005 at 8:39 am
Hi Folks,
My SQL Server registration name is TEAM01\ERDEM
I want to connect to this SQL Server databases via .NET. But I always get an error message.
public
static string connectionString = "server=TEAM01\ERDEM database=Northwind;User ID=sa;Password=mlsqlsys;"
How can I rename this SQL Server registration or how can I connect via .NET with this registration name?
Please help
January 25, 2005 at 8:45 am
Missing a semi-colon between server and database.
January 25, 2005 at 9:01 am
Thanks for your reply.But When I put a semicolon then I will get the same error message:
-----------------------------------------------------------
public
static string connectionString = "server=TEAM01\xxxx;database=Northwind;User ID=sa;Password=mlsqlsys;";
----------------------------------------------------------
January 25, 2005 at 9:25 am
It is generally useful to include the actual text of the error message.
January 25, 2005 at 9:46 am
check out this url
January 25, 2005 at 10:46 am
I would try putting the servername like [TEAM01\XXXX]
oh.. and please tell me the password supplied is not the REAL one... IF it is I would probably modify my post and change it....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
January 25, 2005 at 11:05 am
Or change it altogether and change the post to XXX just so that noone decides to try to hack your server.
January 25, 2005 at 11:39 am
I don't understand why you can't connect to your server... I connected just fine
January 26, 2005 at 7:01 am
I'm surprised you even compiled. When I try to compile your code, I get an "Unrecognized escape sequence", which is roughly what I expected.
In C#, the "\" in a string literal signifies that the following character should be treated special. For example "\t" means interpret the "t" as a "tab". And "\n" means interpret the "n" as a "newline". To actually include a "\" in your string, you need to tell C# to interpret the "\" as a "\" by included two "\" as follows:
public static string connectionString = "server=TEAM01\\xxxx;database=Northwind;User ID=sa;Password=xxxxxx;";
Alternatively, you can tell C# to interpret the quoted string exactly as written by prefacing with a "@" as follows:
public static string connectionString = @"server=TEAM01\xxxx;database=Northwind;User ID=sa;Password=xxxxxx;";
Step through your code in debug mode and check that the connectionString variable contains exactly what you think it should.
January 26, 2005 at 8:25 am
Just a thought in case you were planning to use sa. You may want to reconsider this. The sa user should never be used within an application. A specific id with minimal authority should be used.
btw the connectionstring.com site is a great reference. I didn't know about it.
Francis
January 27, 2005 at 1:02 am
Thanks for your attentions...
I have solved the problem by using "\\" instead of "\"
I have also modified by connedtion string with all of your guidance as follows:
--------------------------------------------------------------------
public
static string connectionString = "server=TEAM01\\ERDEM;database=ML2005;User ID=erdem_01;Password=SE7377;";
-------------------------------------------------------------------
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply