Data type mismatch in criteria expression.
I'm currently building an application that acts as a front-end to a MS Access database. I've put all of my queries into Access and run them from my VB program as stored procedures. I've found on some forms I will get a "System.Data.OleDb.OleDbException was unhandled" error. This happens only if I do not change the value in the DateTimePicker I have on the form. If I do change the value to a date other than today, the procedure runs fine. Here is the code in VB and the SQL statement from Access. Thanks for any help!
'Initialize a new instance of the OleDbConnection Class
objConnection = New OleDbConnection(strConnectionString)
'Initialize a new instance of the OleDbCommand class
objCommand = New OleDbCommand
'Set the objCommand object properties
Try
objConnection.Open()
Catch OleDbExceptionErr As OleDbException
MessageBox.Show(OleDbExceptionErr.Message, "Container Opening")
Catch InvalidOperationExceptionErr As InvalidOperationException
MessageBox.Show(InvalidOperationExceptionErr.Message, "Container Opening")
End Try
With objCommand
.CommandText = "usp_UpdateOpen"
.CommandType = CommandType.StoredProcedure
.Connection = objConnection
End With
'Add the required parameters for the query
objCommand.Parameters.Add("@SealNumber", OleDbType.Char).Value = txtSealNumber.Text
objCommand.Parameters.Add("@SealLocation", OleDbType.Char).Value = strSealLocation
objCommand.Parameters.Add("@ContainerOpened", OleDbType.DBTimeStamp).Value = dtpOpened.Value
objCommand.Parameters.Add("@ContainerLocation", OleDbType.Char).Value = strContainerLocation
objCommand.Parameters.Add("@ContainerStatus", OleDbType.Char).Value = "Airing"
objCommand.Parameters.Add("@ExamID", OleDbType.Char).Value = cbxFileNumber.Text
objCommand.ExecuteReader()
'Clean up
objCommand.Dispose()
objCommand = Nothing
objConnection.Close()
objConnection.Dispose()
objConnection = Nothing
UPDATE Exams SET SealNumber = [@SealNumber], SealLocation = [@SealLocation], ContainerOpened = [@ContainerOpened], ContainerLocation = [@ContainerLocation], ContainerStatus = [@ContainerStatus]
WHERE ExamID=[@ExamID];

