C# 我无法访问下面语句中的str obj进行连接。为什么?
我无法访问下面语句中的str obj进行连接,为什么?示例文档显示需要将连接字符串传递给构造函数:C# 我无法访问下面语句中的str obj进行连接。为什么?,c#,mysql,C#,Mysql,我无法访问下面语句中的str obj进行连接,为什么?示例文档显示需要将连接字符串传递给构造函数: string str = "server= xxx.xxx.xxx.xxx;Initial Catalog= hgjhg;User Id=root;Password= jhgjhg@123"; MySqlConnection connection = new MySqlConnection(); 不要在这里共享ip地址。只需提供一些垃圾ip地址。@Venkataraman我为他们删除了它。@
string str = "server= xxx.xxx.xxx.xxx;Initial Catalog= hgjhg;User Id=root;Password= jhgjhg@123";
MySqlConnection connection = new MySqlConnection();
不要在这里共享ip地址。只需提供一些垃圾ip地址。@Venkataraman我为他们删除了它。@YannickMeeus ThanksYeah,恐怕对此无能为力:您必须将connectionstring传递给构造函数。MySqlConnection=newmysqlconnectionstr;
string connStr = "server=localhost;user=root;database=world;port=3306;password=******";
MySqlConnection conn = new MySqlConnection(connStr);