且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用c#连接到Mysql数据库

更新时间:2022-10-16 20:23:30

使用此:

  string  connString =  @  SERVER = example.com; DATABASE = db_beta; UID = db_demo; PASSWORD = a~Sz4x; 1)X(N;; 





如需了解更多信息,请参阅: 2.4.4.5字符串文字 [ ^ ]


试试这个:

  string  connString =  @  SERVER = example.com; DATABASE = db_beta; UID ='db_demo'; PASSWORD ='a~Sz4x; 1)X(N'; ; 





或者这个:



  string  connString =   SERVER = example.com +  ; + 
DATABASE = db_beta; +
UID ='db_demo'; +
PASSWORD = 'A〜Sz4x; 1)X(N';跨度>;


I am trying to connect to an Mysql database through c# web service
The password for the database is a~Sz4x;1)X(N The above password has ;(SPECIAL CHARACTER) in it which is a line terminator in c# it throws below error

Format of the initialization string does not conform to specification starting at index 70.

Any help will be appreciated.

Use this:
string connString = @"SERVER=example.com;DATABASE=db_beta;UID=db_demo;PASSWORD=a~Sz4x;1)X(N;";



For further information, please see: 2.4.4.5 String literals[^]


Try this :
string connString = @"SERVER=example.com;DATABASE=db_beta;UID='db_demo';PASSWORD='a~Sz4x;1)X(N';";



or this:

string connString = "SERVER=example.com" + ";" +
"DATABASE=db_beta;" +
"UID='db_demo';" +
"PASSWORD='a~Sz4x;1)X(N';";