none
data type mismatch RRS feed

  • Question

  • i have an access db that i need to search based on the date field i am using the following code

    <in button click>

    updategrid("SELECT * FROM {name of my date base} WHERE DateContacted <> '1-january-2007'")

    sub updategrid(byval sqlStr as string)

    dim dt as datatable

    dim connStr as string = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = {name of data base.mdb}

    dim dataAdapter as new Oledb.OledbdataAdapter(sqlStr, connStr)

    dataAdapter.fill(dt)

    dataAdapter.dispose()

    if dt.rows.count=0 then

    msgbox"No Record Found"

    else

    dgv.datasource=dt

    end sub

     

    the column in the details view is a date time picker and i need to display in dgv

    the properties of the d/t picker format are set to custom dd-MM-yyyy

    i keep getting an error that says it cant complete the sub because there is a data type mismatch and i dont know why

    any help i can get with this would be very appreciated.

    Thank you 

    Tuesday, November 6, 2007 6:16 AM

Answers

  • Hi,

     

    instead of this line:

    updategrid("SELECT * FROM {name of my date base} WHERE DateContacted <> '1-january-2007'")

     

    try to use:

    updategrid("SELECT * FROM {name of my date base} WHERE DateContacted <> #1-january-2007#")

    in sql statment put the date between ## instead of single quotation ' '.

     

    or actually use OleDbParameter to send the date as an argument in a sql statment.

     

    Tuesday, November 6, 2007 6:53 AM

All replies

  • Hi,

     

    instead of this line:

    updategrid("SELECT * FROM {name of my date base} WHERE DateContacted <> '1-january-2007'")

     

    try to use:

    updategrid("SELECT * FROM {name of my date base} WHERE DateContacted <> #1-january-2007#")

    in sql statment put the date between ## instead of single quotation ' '.

     

    or actually use OleDbParameter to send the date as an argument in a sql statment.

     

    Tuesday, November 6, 2007 6:53 AM
  • thank you very much fo rthe help cant believe it was that easy

     

    Thanks

    Thursday, November 8, 2007 3:02 AM