Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# sqldatasource
while connection to the server i found the error , it will not accept special characters. i tried using % before and after the special character then also it showing errors.
string sqlConn = "Data Source=USER-PC%'"+\+"' %CompanyName';Initial Catalog=rack;User ID=trial;Password=trial112";
Please solve this error
Posted 26-Aug-12 20:54pm
Edited 26-Aug-12 21:08pm
Mehdi Gholam262.7K
Zoltán Zörgő at 27-Aug-12 2:09am
I suppose the USER-PC is the machine running the SQL server, but is the CompanyName the fixed instance name of the SQL server as you see it in the service manager, or is it a variable? In the second case you mean that the USER-PC machine is running several different instances of SQL server?
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

string sqlConn =@"Data Source=USER-PC;Initial Catalog=rack;User ID=trial;Password=trial112";[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this:
string sqlConn = "Data Source=USER-PC\\CompanyName;Initial Catalog=rack;User ID=trial;Password=trial112";
If it's local PC, use dot as :
"Data Source=.;Ini.....
If you are struggling with name try to ping User-PC\CompanyName...
The syntax of connection is:
Server\Instance, Port
Default port(SQL) - 1433
Verify you can connect.
When you initialize any string make sure that escape special charcters..
\ is a special charcater and you need to escape it as \\
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

string sqlConn = "Data Source=USER-PC\CompanyName;Initial Catalog=rack;User ID=trial;Password=trial112";
see data-source value it should be same as you find in login window while open your sql server
'server name' = xyz\SQLEXPRESS
connection string should like below
string sqlConn = "Data Source=xyz\SQLEXPRESS;Initial Catalog=rack;User ID=trial;Password=trial112";
Happy Coding!
Smile | :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 Maciej Los 285
2 OriginalGriff 285
3 Peter Leow 260
4 John C Rayan 162
0 Sergey Alexandrovich Kryukov 7,203
1 OriginalGriff 5,587
2 Peter Leow 4,097
3 Mika Wendelius 2,850
4 CHill60 2,818

Advertise | Privacy | Mobile
Web04 | 2.8.150224.1 | Last Updated 27 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100