MySQL Paramatirzation not working using mysql.data.dll
The following is my code it does an insert into the database but the valu开发者_如何转开发es are not parametrized.
http://pastebin.com/h04UhcYv
Everything just shows up as null.
instead of using Parameters.Add() try using Parameters.AddWithValue(), for example:
using (MySqlConnection oCon = new MySqlConnection("connectionString"))
{
string sql = "INSERT INTO table(column) VALUES(@column)";
MySqlCommand oCom = new MySqlCommand(sql, oCon);
oCom.Parameters.AddWithValue("@column", "value");
oCon.Open();
oCom.ExecuteNonQuery();
oCon.Close();
}
Seems your code it's fine but also you can check what DLL version of MySql.Data you are using, and the value that you are sending to the procedure.
As a bit of advice, the connection object should be opened just before the command is executed, also it's a good practice to use the statement using as this will dispose the object after termination.
精彩评论