Community discussion forum

help me sql string error

Tags: db, vb6 India
  • 1 year ago

    i have a problem. i make database using VB6 and MS Access.  components (Adodc, Datagrid )

    An errror occurs "Data type mismatch in criteria expression " 

    in MS Access, data type of field name "date" is Data/Time.

    i use sql command string. i want to use "greater than or less than" in sql command and show in Datagrid. please help me.

    Private Sub Findcmd_Click()
    ADO.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\ss.mdb;Persist Security Info=False"
    ADO.RecordSource = "select * from table where date < '" & search.Text & "'"
    Set DG.DataSource = ADO
    End Sub

     

  • 1 year ago

    Hi

    You are treating the date is SQL like a string.

    In SQL for Access (Jet) you must put hash symbols # around a date

    where date < '" & search.Text & "'"
    Should be
    where date < #" & search.Text & "#"

  • 1 year ago

    Thanks a lot. Jugatsu

    you are great! thanks for your advice.

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback