Data Type Mismatch with Number (not date)

Results 1 to 4 of 4

Thread: Data Type Mismatch with Number (not date)

  1. #1
    Ceejay Guest

    Default Data Type Mismatch with Number (not date)

    Trying to check an employee number and last four digits in the SSN posted from a form against a database with EmpID and SSN formatted as numbers (long integer). Script for the query is as follows:<BR><BR>&#060;% Response.buffer=True<BR><BR>Dim Cm, Rs, SSN, EmpID<BR><BR>SSN=Request.Form("SSN")<BR>EmpID=Requ est.Form("EmpID")<BR><BR>Session("SSN") rm("SSN")<BR>Session("EmpID")=request.form("EmpID" ) <BR>Set Cm = Server.CreateObject("ADODB.Command")<BR><BR> Cm.ActiveConnection = "DSN=webdata;DRIVER={Microsoft Access Driver(*.mdb)}"<BR><BR> Cm.CommandText = "SELECT * FROM tblEmpData WHERE " & _<BR> "SSN=&#039;" & Request.Form("SSN") & "&#039; AND " & _<BR> "EmpID=&#039;" & Request.Form("EmpID") & "&#039; "<BR><BR> Cm.CommandType = 1<BR> <BR> <BR> Set Rs = Cm.Execute<BR><BR>Running the script produces the &#039;data type mismatch&#039; error in the criteria statement. What am I missing? Thanks for any help.<BR>

  2. #2
    Join Date
    Dec 1969

    Default Read the ASPFAQ again...

    ...when you compare vs. numeric fields you MUST NOT use &#039;...&#039; around the values you are comparing to.<BR><BR>Note that this will *NOT* help you compare last 4 digits of SSN! (Assuming that the DB contains all digits...if it only contains 4 then you are in fine shape...except for the bogus &#039;...&#039; stuff.)<BR><BR>

  3. #3
    Bill Wallace Guest

    Default RE: Data Type Mismatch with Number (not date)

    The single quotes around the variables<BR>in your SELECT statement make them strings.<BR><BR>You might also want to try:<BR><BR>Session("SSN")=CInt(request.form("SSN" ))<BR>Session("EmpID")=CInt(request.form("EmpID")) <BR><BR>or maybe CLong<BR><BR>and<BR><BR>Cm.CommandText = "SELECT * FROM tblEmpData WHERE " & _<BR>"SSN=" & SSN & " AND " & _<BR>"EmpID=" & EmpID<BR><BR><BR>

  4. #4
    Ceejay Guest

    Default RE: Data Type Mismatch with Number (not date)

    Thanks, Bill Wallace- The trees and the forest syndrome- I feel like I just walked smack into a tree. The quotes and apostrophes seem to give me the worst time. Thanks again for a sincere response.

Posting Permissions

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