public string DeleteWatchReceipt(DateTime date) { OleDbConnection conn = new OleDbConnection("My DB path")); string sqlinsert = @"DELETE WatchreceiptID FROM Watchreceipt WHERE Dato = " + date; conn.Open(); OleDbTransaction sqltrans = conn.BeginTransaction(); string result = null; try { OleDbCommand cmdinsert = conn.CreateCommand(); cmdinsert.CommandText = sqlinsert; cmdinsert.Transaction = sqltrans; cmdinsert.ExecuteNonQuery(); sqltrans.Commit(); result = "Ok"; } catch (OleDbException odbe) { sqltrans.Rollback(); System.Windows.Forms.MessageBox.Show("Rolled back\n" + odbe.Message); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Systemfejl\n" + ex.Message); } finally { conn.Close(); } return result; }
string sqlinsert = @"DELETE WatchreceiptID FROM Watchreceipt WHERE Dato = '" + date + "'"; // preferably : date.ToString("yyyy-MM-dd");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)