You have to call cmd.ExecuteNonQuery() to run the query...
c# Insert lines into a database issue

elfenliedtopfan5
121
Reputation points
Hello all that read,
i have written a little code to insert lines into a database i get a success message but nothing is appearing in the database it still blank,
code below,
try
{
Nao_Res.conn = new MySqlConnection();
Nao_Res.conn.ConnectionString = Nao_Res.connString;
Nao_Res.conn.Open();
MySqlCommand cmd = new MySqlCommand("INSERT INTO `Applications_Setup`(`Application`, `Installed`, `Description`) VALUES ('"+Nao_Res.Name+"','"+Nao_Res.AppName+"','"+"Photoshop this is a test for database"+"')");
XtraMessageBox.Show("Added");
Nao_Res.conn.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
XtraMessageBox.Show(ex.Message);
}
but unsure of why this is not working i have auto-increment on my id so removed it from the insert but quite sure its not that as should not make a difference if it auto increments,
below is a picture of the db setup on sqlserver,
thanks in advance elfenliedtopfan5