问题
I have problem while connecting to mysql database using "ADO.NET Driver for MySQL (Connector/NET)"
I got this exception The given key was not present in the dictionary.
Edit:
MySqlConnection con = new MySqlConnection("Server=localhost;Database=pgs_db;Uid=root;Pwd=;");
MySqlCommand com = new MySqlCommand();
com.CommandType = CommandType.StoredProcedure;
com.Connection = con;
com.CommandText = "getStudent";
con.Open();
MySqlDataReader dr =com.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
con.Close();
回答1:
Without seeing the code, I am guessing you are trying to access a configuration key that does not exist in your application config file.
Edit: After seeing the code sample, the problem is probably not with connecting to the DB.
I would say that in your GridView
, you are binding to a field that is not returned by the DB query.
回答2:
sorry i was using a worng connectionstring
this is a right one :
"server=localhost; user id=user; password=password; database=mydatabase; pooling=false;"
thnx Oded
来源:https://stackoverflow.com/questions/2176329/error-in-mysql-connection-the-given-key-was-not-present-in-the-dictionary