con.open()期间发生连接错误 [英] Connection error occure during con.open()
问题描述
尝试将MySQL 5.0与ASP.NET结合使用,并且略有挣扎.我正在测试以使其正常运行的代码如下:
DataSet ds = new DataSet(); using (MySqlConnection conn = new MySqlConnection(ConnectionString)) { conn.Open(); MySqlDataAdapter cmd = new MySqlDataAdapter("SELECT * FROM entries", conn); cmd.Fill(ds); conn.Close(); } return ds;
在conn.Open()上调试显示以下错误:
ServerThread = conn.ServerThread引发了type.NullReferenceException类型的异常;
ServerVersion = conn.ServerVersion引发了类型为System.NullReferenceException的异常;
但是,越过整个页面就冻结了.我不确定我做错了什么.我确定我的连接字符串正确,所以我不确定在这里做错了什么.错误消息也不能真正帮助我!
预先加油
它是一个空引用异常,请检查您的连接字符串并使用正确的连接字符串将变量初始化为
< code>
String ConnectionString =您的连接字符串";</code>
该站点还对您有所帮助 http: //www.connectionstrings.com/ [ ^ ]
Trying to use MySQL 5.0 with ASP.NET and struggling slightly. The code I am testing to try and get it working is as follows:
DataSet ds = new DataSet(); using (MySqlConnection conn = new MySqlConnection(ConnectionString)) { conn.Open(); MySqlDataAdapter cmd = new MySqlDataAdapter("SELECT * FROM entries", conn); cmd.Fill(ds); conn.Close(); } return ds;
Debugging on conn.Open() shows the following errors:
ServerThread = conn.ServerThread threw an exception of type.NullReferenceException;
ServerVersion = conn.ServerVersion threw an exception of type System.NullReferenceException;
But stepping past that the whole page just freezes. I am not sure what I have done wrong. I am sure my connection string is right so I am not sure what I have done wrong here. Error message is not really helping me either!
Cheers in advance
Its a null reference exception, Please check your connection string and intialize the variable with the correct connection string as
<code>
String ConnectionString = "your connection string";</code>
this site also helpful to you http://www.connectionstrings.com/[^]
这篇关于con.open()期间发生连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!