I have do some calculation in C# and i want insert that value to MySql database. Example totalPrice= Price1+Price2; I want pass the totalPrice into my table. How to do that?
2 Answers
You need to use an INSERT statement. It's probably best to use parameterized queries rather than just an INSERT command.
MySqlCommand command = new MySqlCommand();
string sql = "INSERT INTO YourTable (TotalPrice) VALUES (@TotalPrice)";
command.Parameters.AddWithValue("@TotalPrice", totalPrice);
Then remember to execute your query. command.ExecuteNonQuery();
1 Comment
Corak
+1 for parameterized queries. Can't be stressed too much to use 'em!