Hi there
I am trying to connect to a SQL database, the default installation of SQL Express installed by Visual Studio Professional. Let me first say I'm coming from a VB6 background, so I know diddly squat about C#. You can consider me a classic case of VDU (Very Dumb User).
My main problem is that I am trying to connect to the sql server by using a connectionstring. I am setting the value of the connection string as follows
ConnecString =
@"Data Source=[GD-MOBILE\SQLEXPRESS];Initial Catalog=PRISM_Test;Integrated Security=true"My problem is that the single backslash is converted to 2 backslashes, and I think this is causing the problem. How do I get just one backslash in there
Thanks
Carlos

Strings
Lampkin
It would have been better if you ahd given the error as well. Anyway in C#, dont use one '\' but two.... like name\\name in a string..........
Chouproute
Hi Rick
Thanks for the response.
So, if I understand you correctly, using the @ symbol negates the need for the escape sequence. But checking the value of the string will still display the two backslashes
Thanks Carlos
NetDragonKing
@Carlos: please read this article, this might help understand why the string is displayed with two backslashes, but actually contains only one. Please give us some more information on the error, so we can help.
Nash Bridges
Connectionstrings:
Standard Windows Authentication:
theConnectionString = "Server=.;Database=pubs;Trusted_Connection=True;";
for local server, enter a period [.]
Username/Password Authentication:
theConnectionString = "Server=.;Database=pubs;User ID=theUserName;Password=thePassword;Trusted_Connection=False;";
if you need to use the backslash, remove the @ and replace the backslash with 2 backslashes. 2 backslashes = 1 backslash in C#
Abhishek Chadha
Hi prashant
I tried you line above, but that didn't work either. I also tried using the default MSDE installation on my computer. I cannot get it to work when the specific server name is used "GD-MOBILE", but it does work when I use "(local)".
Maybe there is an error with my entire thinking
What I am trying to achieve is to create a connection to the database manually, instead of using the wizards. So what I have done is to create OleDBConnection object and created the connectionstring, and then trying to call the Open method
Is this a good/bad/indifferent way of doing it
thanks
Carlos
millerfjtp
The two back-slashes is purely an affect of the debugger. There is really one one back-slash.
SQL Express does not like being accessed from a remote machine. I'm told it is possible, but I've never been able to get it to work.
To access it from the local machine, use
ConnecString = @"Data Source=.\SQLEXPRESS;Initial Catalog=PRISM_Test;Integrated Security=true"
MyClubV2 Support
Hi Carlos,
Please try the below line:
Connecstring = @"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=PRISM_Test;Data Source=GD-MOBILE\SQLEXPRESS"
If you still face the problem please reply.