RE: Date/Time Strange Problem



Try something like this:

cmd.Parameters.Add("@publication_date", DbType.DateTime).Value = DateTime.Now;

"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
>
>
>
>
.



Relevant Pages

  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... Dim Rng As Range ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... I have tried using the custom format, and you're right, it only ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • Re: OleDbDataAdapter question
    ... I would rather use a DataReader to read the records and at the same time ... inserting these records in the second DB. ... Ignacio Machin, ... > I want to copy some record from a Access database to another Access DB. ...
    (microsoft.public.dotnet.languages.csharp)
  • JDBC commit problem
    ... I am working with MS Access database through JDBC. ... The problem arises when I want to view my table just after inserting ... (name, value, prize, date) ...
    (comp.lang.java.databases)
  • Re: JDBC commit problem
    ... I am working with MS Access database through JDBC. ... The problem arises when I want to view my table just after inserting ... (name, value, prize, date) ...
    (comp.lang.java.databases)