c#连接到mysql 的连接字符串怎么写

2024-11-30 20:01:59
推荐回答(1个)
回答1:

String mysqlStr = "Database=test;Data Source=127.0.0.1;User Id=root;Password=root;pooling=false;CharSet=utf8;port=3306";
MySqlConnection mysql = new MySqlConnection(mysqlStr);
或者
string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
"SERVER=localhost;" +
"DATABASE=inv;" +
"UID=root;" +
"PASSWORD=root;" +
"OPTION=3";
OdbcConnection MyConnection = newOdbcConnection(MyConString);