Prev: regular expression with linq to get files from a dir
Next: How to identify control which was _right_ clicked?
From: trant on 23 Feb 2010 20:46 I have having difficulty figuring out how to insert into a MySql database using C# and MySql Connector. I looked over several tutorials now I I seem to have everything correct but for some reason values never get inserted into my table, everything is NULL! here is my code: MySqlConnection connection = new MySqlConnection(MyConString); connection.Open(); MySqlCommand command = new MySqlCommand("INSERT INTO mytable (name) VALUES (@name)", connection); command.Parameters["@name"].Value = "test"; command.ExecuteNonQuery(); It inserts a row into my table but everything is NULL. If I run this same query right into a mysql console (substituting the parameter of course_ it works fine. What did I do wrong? |