B
Brian Henry
I have an access database, and one of the fields in the table I am inserting
into has a date/time data type. What is the correct OleDb data type to
insert the date and time that it is at the moment that the record was
inserted at. I had this, but it gives me a "data type mismatch" error on
run.
Dim cmdPostQuestion As New OleDb.OleDbCommand("INSERT INTO hd_questionsasked
(askedBy,questionText,dateAsked) VALUES (?,?,?)")
cmdPostQuestion.Connection = dbConnection
If dbConnection.State = ConnectionState.Closed Then
dbConnection.Open()
End If
cmdPostQuestion.Parameters.Add("askedBy", OleDb.OleDbType.VarWChar).Value =
getUserName()
cmdPostQuestion.Parameters.Add("dateAsked", OleDb.OleDbType.DBDate).Value =
Now.Date
cmdPostQuestion.Parameters.Add("questionText",
OleDb.OleDbType.VarWChar).Value = Me.txtAskedQuestion.Text
cmdPostQuestion.ExecuteNonQuery()
dbConnection.Close()
if i take out anything relateing to the date, it works just fine...
into has a date/time data type. What is the correct OleDb data type to
insert the date and time that it is at the moment that the record was
inserted at. I had this, but it gives me a "data type mismatch" error on
run.
Dim cmdPostQuestion As New OleDb.OleDbCommand("INSERT INTO hd_questionsasked
(askedBy,questionText,dateAsked) VALUES (?,?,?)")
cmdPostQuestion.Connection = dbConnection
If dbConnection.State = ConnectionState.Closed Then
dbConnection.Open()
End If
cmdPostQuestion.Parameters.Add("askedBy", OleDb.OleDbType.VarWChar).Value =
getUserName()
cmdPostQuestion.Parameters.Add("dateAsked", OleDb.OleDbType.DBDate).Value =
Now.Date
cmdPostQuestion.Parameters.Add("questionText",
OleDb.OleDbType.VarWChar).Value = Me.txtAskedQuestion.Text
cmdPostQuestion.ExecuteNonQuery()
dbConnection.Close()
if i take out anything relateing to the date, it works just fine...