I've been trying all day, but despite there being no error, I can't insert anything at all to my table. I don't know what is honestly wrong with the code, since the data I'm sending is correct, unless there is something missing in my sintax.
It just executes the code but won't insert the new row. The other functions in the form that use for example SELECT work just fine.
public static string constr = @"Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\cybercafe.mdf;
Integrated Security=True;User Instance=True;";
public SqlConnection myConnection = new SqlConnection(MainContainer.constr);
string sqlIns = "INSERT INTO [Programs] (CodProgram, directory, logo ,description ,class ,type) VALUES (@codprogram,@directory,@logo,@description,@class,@type)";
myConnection.Open();
try
{
SqlCommand cmdIns = new SqlCommand(sqlIns, myConnection);
cmdIns.Parameters.AddWithValue("@codprogram",idprogram);
cmdIns.Parameters.AddWithValue("@directory", "'shortcuts\\" +txtname.Text +".lnk'");
cmdIns.Parameters.AddWithValue("@logo", "'icons\\" + txtname.Text + ".jpg'");
cmdIns.Parameters.AddWithValue("@description", txtdescription.Text);
cmdIns.Parameters.AddWithValue("@class", class);
cmdIns.Parameters.AddWithValue("@type", type);
cmdIns.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
myConnection.Close();
Thanks in advance guys.