我在线路上遇到错误.打开():
there is no MysqL host with this parameters.
我已经检查过,一切似乎都很好.
string MyConString = "SERVER=MysqL7.000webhost.com;" + "DATABASE=a455555_test;" + "UID=a455555_me;" + "PASSWORD=something;"; MysqLConnection connection = new MysqLConnection(MyConString); MysqLCommand command = connection.CreateCommand(); MysqLDataReader Reader; command.CommandText = "INSERT Test SET lat=" + OSGconv.deciLat + ",long=" + OSGconv.deciLon; connection.open(); Reader = command.ExecuteReader(); connection.Close();
这个连接字符串有什么问题?
解决方法 尝试创建连接字符串这样:MysqLConnectionStringBuilder conn_string = new MysqLConnectionStringBuilder();conn_string.Server = "MysqL7.000webhost.com";conn_string.UserID = "a455555_test";conn_string.Password = "a455555_me";conn_string.Database = "xxxxxxxx";using (MysqLConnection conn = new MysqLConnection(conn_string.ToString()))using (MysqLCommand cmd = conn.CreateCommand()){ //watch out for this sql injection vulnerability below cmd.CommandText = string.Format("INSERT Test (lat,long) VALUES ({0},{1})",OSGconv.deciLat,OSGconv.deciLon); conn.open(); cmd.ExecuteNonquery();}总结
以上是内存溢出为你收集整理的c# – 如何形成一个正确的MySQL连接字符串?全部内容,希望文章能够帮你解决c# – 如何形成一个正确的MySQL连接字符串?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)