none
MS Access Query Parameters - Data Type Mismatch in VB RRS feed

  • Question

  • I am having trouble with running a MS Access Query from VB.NET.
    ....
    dbConn.dbCOMMAND.CommandText = "qry_GetUtilizationByEmployeeByProject"
    dbConn.dbCOMMAND.Parameters.AddWithValue("ProjectIDNumber", pid)
    dbConn.dbCOMMAND.Parameters.AddWithValue("MinPeriod", minPeriod)
    dbConn.dbCOMMAND.Parameters.AddWithValue("MaxPeriod", maxPeriod)
    dbreader = dbConn.dbCOMMAND.ExecuteReader()
    ....
    dbConn is a database connection object and dbCOMMAND is an OleDbCommand.

    pid is an integer
    minPeriod, maxPeriod are DateTime

    When i run it i get a datatype mismatch error. If I modify the query and only pass the int or only pass the DateTime's it works fine. I only get this error when I mix the datatyeps as parameters. The query, in MS Access works fine when I type in the values

    Can someone help solve this using the OleDbCommand method above??
    Wednesday, September 8, 2010 2:46 PM

All replies

  • Could you post the query? I'm assuming that the Access QueryDef has three parameters?
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, September 8, 2010 5:44 PM
  • Hello,

    Is there any updates? Can you please provide us more information? Is there any error message/call stack?

    Please take a look at this walkthrough to retrieve data in Access using ADO.NET and C#, I believe it could help you:
    http://support.microsoft.com/kb/308100/en-us

    Best regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    Friday, September 10, 2010 8:19 AM