Hello, I am trying to insert rows into an existing database using the below logic. I receive no errors, if I do not properly specify a FK it will error, so I am assuming it does the commit. However using server explorer or a datagrid I never see any data. Any help would be greatly appreciated.
try
conn = new SqlCeConnection(@"Data Source=|DataDirectory|\MediaLister.sdf");
conn.Open();
trans = conn.BeginTransaction();
SqlCeCommand insertMedia = conn.CreateCommand();
String insertMediaSql = "INSERT INTO Media(MediaName, MediaType, MediaLength, MediaDescription)" +
"VALUES ('MediaName', 'DVD', 'MediaLength', 'MediaDescription')";
// "VALUES (@MediaName, @MediaType, @MediaLength, @MediaDescription)";
insertMedia.Transaction = trans;
insertMedia.CommandText = insertMediaSql;
insertMedia.ExecuteNonQuery();
trans.Commit(
}
{
System.Windows.Forms.
conn.Close();
Many thanks in advance. Jeremy