string str = "server= xxx.xxx.xxx.xxx;Initial Catalog= hgjhg;User Id=root;Password= jhgjhg@123";
MySqlConnection connection = new MySqlConnection();
我无法在下面的语句中访问str obj来连接,为什么?
答案 0 :(得分:1)
从MySqlConnection的文档中,示例显示您需要将连接字符串传递给构造函数:
string connStr = "server=localhost;user=root;database=world;port=3306;password=******";
MySqlConnection conn = new MySqlConnection(connStr);