Data Type mismatch

Results 1 to 3 of 3

Thread: Data Type mismatch

  1. #1
    Join Date
    Dec 1969

    Default Data Type mismatch

    I am receiving an error for a data type mismatch. It points to the line set rs=DbConn.Execute(sql)<BR><BR>[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. <BR><BR>Here is the code.<BR><BR>&#060;%<BR> &#039;declare the variables<BR> DIM ID,Refer,rs,varBookMark,sql<BR><BR> &#039;grab the id variable from the querystring<BR> ID = Request.QueryString("id")<BR> &#039;grab the users previous location<BR> Refer = Request.ServerVariables("HTTP_REFERER")<BR> <BR> sql = "SELECT * FROM EmailList WHERE Email=" & Request.QueryString("id") <BR> Set rs = DbConn.Execute(sql)<BR> &#039;keep our current place<BR> varBookmark = objRec.Bookmark<BR> rs.MoveFirst<BR> &#039;loop through the records<BR> While Not rs.EOF<BR> &#039;test to see if it is the correct record<BR> If (rs("id") = ID) THEN<BR> &#039;if so, bookmark the record<BR> varBookmark = rs.Bookmark<BR> End If<BR> &#039;move to the next record<BR> rs.MoveNext<BR> Wend<BR><BR> &#039;set the recordset to the correct record<BR> rs.Bookmark = varBookmark<BR><BR> &#039;delete the record<BR> sql = "DELETE * FROM EmailList WHERE Email=" & Request.QueryString("ID") <BR> DbConn.Execute(sql)<BR> &#039;clean everything up<BR> DbConn.Close<BR> Set DbConn = Nothing<BR> Set rs = nothing<BR> Set sql = nothing<BR> &#039;redirect the user to where they came from<BR> Response.Redirect(Refer)<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Data Type mismatch

    Do you have the line:<BR>set rs = Server.CreateObject("adodb.Recordset")<BR><BR>befo re this line?:<BR> <BR>Set rs = DbConn.Execute(sql)<BR><BR>I am assuming you have assigned the connection DbConn correctly.<BR><BR>Paulee<BR>

  3. #3
    Join Date
    Dec 1969

    Default Since you are getting an ODBC

    error(database error), its most likely because you did not put value in &#039; characters like following:<BR><BR>sql = "SELECT * FROM EmailList WHERE Email=&#039;" & Request.QueryString("id") &"&#039;"<BR><BR>This is a very common mistake. Remember you are building a SQL statement here so you have to follow the proper SQL syntax.<BR><BR>Hope that helps.<BR><BR>Pete

Posting Permissions

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