ASP Data type mismatch in criteria expression.

Discussion in 'C#' started by james6380, Dec 21, 2008.

  1. #1
    I have checked the DB.MDB which is located in admin\db.mdb

    Table Name: Enquiry

    Field Names Below
    --------------------

    NewEnquiryID < Auto Number
    EnquirtyType
    FName
    LName
    Telephone
    Time
    EmailAddress
    DateFrom
    Nights
    Adults
    Child
    Notes
    DateSent

    I keep getting the following error message this works with out he DB Insert form.

    <%
    
    dim FName
    dim LName
    dim EnquiryType
    dim Telephone
    dim Time
    dim EmailAddress
    dim DateFrom
    dim Nights
    dim Adults
    dim Child
    dim notes
    dim DateSent
    
    FName=request.form("FName")
    LName=request.form("LName")
    EnquiryType=request.form("EnquiryType")
    Telephone=request.form("Telephone")
    Time=request.form("Time")
    EmailAddress=request.form("EmailAddress")
    DateFrom=request.form("DateFrom")
    Nights=request.form("Nights")
    Adults=request.form("Adults")
    Child=request.form("Child")
    notes=request.form("notes")
    DateSent=request.form("DateSent")
    
    Set db = Server.CreateObject("ADODB.Connection")
    db.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("admin\db.mdb") & ";"
    
    db.execute("INSERT INTO Enquiry ([FName], [LName], [EnquiryType], [Telephone], [Time], [EmailAddress], [DateFrom], "&_
    	"[Nights], [Adults], [Child], [Notes], [DateSent]) VALUES ('" & FName & "','" & LName & "','" & EnquiryType & "','"&_
    	Telephone & "','" & Time & "','" & EmailAddress & "','" & DateFrom & "','" & Nights & "','" & Adults & "','" &_
    	Child & "','" & notes & "','" & DateSent & "')")
    
      db.close
    set db=nothing
    Code (markup):

    Microsoft JET Database Engine error '80040e07'

    Data type mismatch in criteria expression.

    /james/send.asp, line 32


    Line 32 is
    db.execute("INSERT INTO Enquiry ([FName], [LName], [EnquiryType], [Telephone], [Time], [EmailAddress], [DateFrom], "&_
    	"[Nights], [Adults], [Child], [Notes], [DateSent]) VALUES ('" & FName & "','" & LName & "','" & EnquiryType & "','"&_
    	Telephone & "','" & Time & "','" & EmailAddress & "','" & DateFrom & "','" & Nights & "','" & Adults & "','" &_
    	Child & "','" & notes & "','" & DateSent & "')")
    Code (markup):
     
    james6380, Dec 21, 2008 IP
  2. hajan

    hajan Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you please give us more details regarding all fields DataType which appears in Database.

    Open your Access database, and tell us all field types (ex: varchars, integers, numbers, decimals, chars etc...)

    The error appears when the query is sent to db to be executed, so ... it miss matches.
    Have you tested the same Query in the database?

    Please reply back...
    Hajan
     
    hajan, Dec 22, 2008 IP
  3. dodolls

    dodolls Well-Known Member

    Messages:
    282
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #3
    I believe you are using Integer for the "nights, adults, and child" fields. Try to remove the quotes on them.
     
    dodolls, Dec 22, 2008 IP
  4. hajan

    hajan Peon

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here are the possible DataTypes of the following columns...

    NewEnquiryID < Auto Number (int)
    EnquirtyType (int)
    FName (varchar)
    LName (varchar)
    Telephone (number)
    Time (DateTime)
    EmailAddress (varchar)
    DateFrom (DateTime)
    Nights (int or varchar)
    Adults (int or varchar)
    Child (int or varchar)
    Notes (text or varchar)
    DateSent (DateTime)

    -------------------------------------------

    Now we wait to see your real DataTypes...

    I will propose u to use StoredProcedure in order to avoid such quotation mess ups..

    So, we are waiting for reply from @james6380
     
    hajan, Dec 23, 2008 IP
  5. rajendra.parmar

    rajendra.parmar Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Dear Friend,

    You can not user time as field name, Because time is the data type. you change the filed name time.

    It will work.
     
    rajendra.parmar, Jan 2, 2009 IP
  6. jgarrison

    jgarrison Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Directly under the line DateSent=request.form("DateSent") copy and paste the following:

    Response.Write("INSERT INTO Enquiry ([FName], [LName], [EnquiryType], [Telephone], [Time], [EmailAddress], [DateFrom], "&_
    "[Nights], [Adults], [Child], [Notes], [DateSent]) VALUES ('" & FName & "','" & LName & "','" & EnquiryType & "','"&_
    Telephone & "','" & Time & "','" & EmailAddress & "','" & DateFrom & "','" & Nights & "','" & Adults & "','" &_
    Child & "','" & notes & "','" & DateSent & "')")
    Response.End

    Then copy/paste the SQL statement displayed into an Access query. It will probably give a better clue to the error.

    -Jim
     
    jgarrison, Jan 2, 2009 IP