VB 2008 - How to update DATE field on MS_Access Table

RUIDEOLIVEIRA
RUIDEOLIVEIRA used Ask the Experts™
on
I have the following code in order to insert a record on a Access Table:

        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO Cursos (Sigla, Designacao) " _
        & "VALUES (?, ?)", con)
        cmd.Parameters.AddWithValue("@Sigla", txtSigla.Text.ToString)
        cmd.Parameters.AddWithValue("@Designacao", txtDesignacao.Text.ToString)
****        cmd.Parameters.AddWithValue("@DataInicio", txtDataInicio.Text.ToString)                
****        cmd.Parameters.AddWithValue("@DataFim", txtDataFim.Text.ToString)
        cmd.ExecuteNonQuery()
        Me.CursosTableAdapter.Fill(Me.GestaoHorariosDataSet.Cursos)
        con.Close()

But I receive an error. Thefields on the database are defined as date- shortdate.

How an I do it?

Regards
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Sorry, This is the correct code:

I have the following code in order to insert a record on a Access Table:

        con.Open()
        Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO Cursos (Sigla, Designacao,DataInicio,DataFim) " _
        & "VALUES (?, ?, ?, ?)", con)
        cmd.Parameters.AddWithValue("@Sigla", txtSigla.Text.ToString)
        cmd.Parameters.AddWithValue("@Designacao", txtDesignacao.Text.ToString)
****        cmd.Parameters.AddWithValue("@DataInicio", txtDataInicio.Text.ToString)                
****        cmd.Parameters.AddWithValue("@DataFim", txtDataFim.Text.ToString)
        cmd.ExecuteNonQuery()
        Me.CursosTableAdapter.Fill(Me.GestaoHorariosDataSet.Cursos)
        con.Close()

But I receive an error. Thefields on the database are defined as date- shortdate.

How an I do it?

Regards
Tags:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial