初始化连接
System.ArgumentException:'Format of the initialization string does not conform to specification starting at index 17'
此行显示上述错误消息
private void InitializeConnection()
{
server = "localhost";
database = "table";
uid = "root";
password = "";
string connectionString = "SERVER=" + server + ";" + "DATABASE" + database + ";" + "UID" + uid + ";" + "PASSWORD" + password + ";";
ObjConnection = new MySqlConnection(connectionString); // error happens here
}
最佳答案
在DATABASE
附近的代码中应该类似于DATABASE=
,UID
和PASSWORD
也是如此。所有你在这些变量附近都错过了=
private void InitializeConnection()
{
server = "localhost";
database = "table";
uid = "root";
password = "";
string connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
ObjConnection = new MySqlConnection(connectionString);
}
关于c# - 我如何在我的项目中解决初始化字符串的格式不符合从索引 17' 开始的规范,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51107048/