B
Berend
when I try to write to a database I get a syntax error
I made the code a simple as possible bur also the VS generated code
gives the same error. WHY?
private void button1_Click(object sender, System.EventArgs e)
{
string strSQL;
strSQL = "INSERT INTO Overwerk(datum , begin, eind, omschrijving)
VALUES('10-01-2004', '12:00', '16:00', 'Test')";
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\data\\Uren.MDB";
OleDbConnection oleDbConnUren = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, oleDbConnUren );
try
{
oleDbConnUren.Open();
myCmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error:\n{0}", ex.Message);
}
finally
{
oleDbConnUren.Close();
}
}
I made the code a simple as possible bur also the VS generated code
gives the same error. WHY?
private void button1_Click(object sender, System.EventArgs e)
{
string strSQL;
strSQL = "INSERT INTO Overwerk(datum , begin, eind, omschrijving)
VALUES('10-01-2004', '12:00', '16:00', 'Test')";
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\data\\Uren.MDB";
OleDbConnection oleDbConnUren = new OleDbConnection(strDSN);
OleDbCommand myCmd = new OleDbCommand( strSQL, oleDbConnUren );
try
{
oleDbConnUren.Open();
myCmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error:\n{0}", ex.Message);
}
finally
{
oleDbConnUren.Close();
}
}