|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strange Date/Time problemI am having an error when inserting a record in an Access database. The field [publication_date] is of Date/Time type. This is my query and the parameters for that field: Dim queryString As String = "INSERT INTO [t_news] ([title], [text], [publication_date]) VALUES (@title, @text, @publication_date)" Dim dbCommand As IDbCommand = New OleDbCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection With dbCommand.Parameters .Add(New OleDbParameter("@title", "sample")) .Add(New OleDbParameter("@text", "sample")) .Add(New OleDbParameter("@publication_date", DateTime.Now)) End With I get the error "Data type mismatch in criteria expression." What is wrong here? Thanks, Miguel Shapper,
I think you are using the wrong oledbparameter overload constructor. Try: dbCommand.Parameters.Add("@publication_date", OleDbType.DBTimeStamp).Value = DateTime.Now AMB Show quote "Shapper" wrote: > Hello, > > I am having an error when inserting a record in an Access database. > > The field [publication_date] is of Date/Time type. > > This is my query and the parameters for that field: > > Dim queryString As String = "INSERT INTO [t_news] ([title], [text], > [publication_date]) VALUES (@title, @text, @publication_date)" > > Dim dbCommand As IDbCommand = New OleDbCommand > dbCommand.CommandText = queryString > dbCommand.Connection = dbConnection > > With dbCommand.Parameters > .Add(New OleDbParameter("@title", "sample")) > .Add(New OleDbParameter("@text", "sample")) > .Add(New OleDbParameter("@publication_date", DateTime.Now)) > End With > > I get the error "Data type mismatch in criteria expression." > > What is wrong here? > > Thanks, > Miguel > > |
|||||||||||||||||||||||