I am using Visual Studio 2003, C# .NET
I can't get this INSERT statement to work. I can get an UPDATE to work, but not this INSERT. Here is my code...
*************** ***
*************** **
I can't get this INSERT statement to work. I can get an UPDATE to work, but not this INSERT. Here is my code...
*************** ***
Code:
//opens database
string conString = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=C:\\TimeClock\\TimeClock.mdb";
OleDbConnection empConnection = new OleDbConnection(conString);
//add time clocked in/out in clock table
string insertStatement = "INSERT INTO Clock "
+ "(Login, Time, Status) "
+ "VALUES (?, ?, ?)";
OleDbCommand insertCommand = new OleDbCommand(insertStatement, empConnection);
insertCommand.Parameters.Add("Login", OleDbType.Char).Value = strLogin;
insertCommand.Parameters.Add("Time", OleDbType.Char).Value = strTime;
insertCommand.Parameters.Add("Status", OleDbType.Char).Value = strStatus;
empConnection.Open();
try
{
int count = insertCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
empConnection.Close();
}
Comment