www.webdeveloper.com
Results 1 to 6 of 6

Thread: Confusing error - data type mismatch

  1. #1
    Join Date
    May 2003
    Location
    New York
    Posts
    279

    Confusing error - data type mismatch

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression
    .........line 214

    Dim Releases: Releases = request.form("Releases")

    Set compareProductRecordset = Server.CreateObject("ADODB.Recordset")


    qryProducts = "SELECT * FROM ProductInfo WHERE ProductsID=" &productsID& " AND VendorID=" &vendorID& " AND Release="&Releases& " AND OSID=" &OSID& " AND StatusID=" &statusID& " AND DateOrdered=" &dateordered



    line 214 is: compareProductRecordset.open qryProducts, oConn

    The weird thing is I get that error only when I add the " AND Release="&Releases& " portion of the query.

    The data type for the Release field in the database is "text".

    I am fairly new to asp, sql, etc.. is that query wrong? Why would only that Release portion of it cause this error?

    I appreciate any help.

  2. #2
    Join Date
    Jun 2004
    Posts
    390
    Try adding single quotes around all your varaibles, SQL usually expects to read a string as "myVariable = 'value'" so for example, ProductsID should read...
    "...ProductsID='" & productsID & "'..."

  3. #3
    Join Date
    May 2003
    Location
    New York
    Posts
    279
    Hi, thanks for your reply.

    I am still getting the error although I might be getting confused with the quotes. Is this right?

    qryProducts = "SELECT * FROM ProductInfo WHERE ProductsID='" &productsID& "' AND VendorID='" &vendorID& "' AND Release='" &Releases& "' AND OSID='" &OSID& "' AND StatusID='" &statusID& "' AND DateOrdered='" &dateordered&"'"

  4. #4
    Join Date
    Jun 2004
    Posts
    390
    The quotes look correct. As a debugging method, Response.Write out the sql string and post what it says... this is an easy way to tell if the quotes are correct and the variable values are there. Another thing you might want to try is adding CStr() around your Releases variable.

  5. #5
    Join Date
    Jun 2005
    Location
    WI, US
    Posts
    188
    try

    qryProducts = "SELECT * FROM ProductInfo WHERE ProductsID=" &productsID& " AND VendorID=" &vendorID& " AND Release='" &Releases& "' AND OSID=" &OSID& " AND StatusID=" &statusID& " AND DateOrdered='" &dateordered&"'"

    this is assuming all your ID fields are integer/number type fields. general rule of thumb, if they are numbers, no quotes. strings need quotes

  6. #6
    Join Date
    May 2003
    Location
    New York
    Posts
    279
    Hi silverbullet24,

    Thanks for your added input - that was actually the solution. Thanks again schizo for your help as well.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles