Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# sqldatasource
Hi
 
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 Gholam249.8K
v2
Comments
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
good
Please Sign up or sign in to vote.

Solution 3

string sqlConn =@"Data Source=USER-PC;Initial Catalog=rack;User ID=trial;Password=trial112";
http://www.connectionstrings.com/[^]
  Permalink  
v2
Rate this: bad
good
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 \\
 
Thanks,
 
Kuthuparakkal
  Permalink  
v3
Rate this: bad
good
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
e.g.
'server name' = xyz\SQLEXPRESS
then
connection string should like below
string sqlConn = "Data Source=xyz\SQLEXPRESS;Initial Catalog=rack;User ID=trial;Password=trial112";
 
Happy Coding!
Smile | :)
  Permalink  

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 295
1 OriginalGriff 274
2 Shweta N Mishra 216
3 PIEBALDconsult 184
4 CPallini 155
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 27 Aug 2012
Copyright © CodeProject, 1999-2014
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