Results 1 to 6 of 6

Thread: Data mismatch

  1. #1
    Join Date
    Feb 2006
    Posts
    72

    Unanswered: Data mismatch

    Hello

    Hoping someone can helpmewith this, please.

    I am getting the following (ASP=MS Access) error:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

    /ASP_Operations.asp, line 34
    Line 34 refers to conn.Execute(SQL)

    The rest of my code is as follows:

    Code:
    <%
    
    Dim conn,rs,SQL,myMail,name,staffID,email,subject,campus,message
    
    'Open MS Access database, store form field values
    
    set conn=Server.CreateObject("ADODB.Connection")
    
    conn.open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("my_database.mdb")& ";"
    
    name = Request.Form("name")
    staffID = Request.Form("staffID")
    email = Request.Form("email")
    subject = Request.Form("subject")
    campus = Request.Form("campus") 
    message = Request.Form("message") 
    
    
    SQL = "INSERT INTO users (name, staffID, email, subject, campus, message) " _
        & " VALUES ('" & name & "', '" & staffID & "','" & email & "', '" & subject & "', '" & campus & "', '" & message & "')"
    
    'Response.Write "DEBUG SQL: " & SQL & "<HR>"
    conn.Execute(SQL)
    
    conn.Close
    Set conn=Nothing
    All fields in the MDB are 'text', except for staffID,which is a number.

    Ideally, I would also like to include a date in one of the columns.

    Any help appreciated.

    Thanks

    Quetzal

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    You wrap text up in apostrophes, dates in hashes and numbers in...nowt.
    Code:
    INSERT INTO tabby (textCol, dateCol, numCol)
    VALUES ('This', #01/01/1932#, 7337)

  3. #3
    Join Date
    Feb 2006
    Posts
    72
    Hello Pootle

    Many thanks for your reply.

    So, 'this' = today's date? Like this:


    Code:
    SQL = "INSERT INTO users (name, staffID, email, subject, campus, message) " _
        & " VALUES ('This' '" & name & "', '" & staffID & "','" & email & "', '" & subject & "', '" & campus & "', '" & message & "')"
    Do I need to add the field in my MDB with the 'date' property?

    Thanks again.

    Quetzal

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    The specific problem was StaffID - you wrapped an integer up in apostrophes. get that right first.

  5. #5
    Join Date
    Feb 2006
    Posts
    72
    Oh, right, thanks. Number take 'nowt', you say. Now I have this:

    Code:
    SQL = "INSERT INTO users (name, staffID, email, subject, campus, message) " _
        & " VALUES ('" & name & "', & staffID &, '" & email & "', '" & subject & "', '" & campus & "', '" & message & "')"
    Cheers

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    nope - wrong again

Posting Permissions

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