Data typr mismatch error

Results 1 to 2 of 2

Thread: Data typr mismatch error

  1. #1
    Join Date
    Dec 1969

    Default Data typr mismatch error

    I have a product detail page that shows an image and some detail info about any product. The page looks for the ProductName vriable from the querystring. I am getting the following error when trying to execute a script.:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e07&#039 <BR>[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. <BR>/bushead/cgi-bin/includes/detail.asp, line 16 <BR><BR><BR>The page is called detail.asp and the querystring is:<BR>detail.asp?ProductCode=4<BR><BR>Here is the code up to line 16:<BR><BR>&#060;%<BR> StrConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=E:blahblahblahproducts.mdb"<BR> Set conn = Server.CreateObject("ADODB.Connection")<BR> conn.Open StrConnect<BR>%&#062;<BR>&#060;form method="Post" action="cgi-bin/includes/addprod.asp"&#062;<BR>&#060;center&#062;<BR>&#060; %<BR>ProductCode = Request.QueryString("ProductCode")<BR>%&#062;<BR>< BR><BR>&#060;%<BR> sql = "SELECT * FROM TblPrducts WHERE (TblPrducts.ProductCode= &#039"&ProductCode&"&#039)"<BR> Set rs = Server.CreateObject("ADODB.Recordset")<BR> rs.Open sql, conn, 3, 3<BR>%&#062;<BR><BR>Thanks!<BR>ScottB

  2. #2
    Join Date
    Dec 1969

    Default RE: Data typr mismatch error

    dont use &#039 " &variable& " &#039 when dealing with numbers. you need to remove the single ticks. When you pass variables into a sql query string use single ticks (&#039) for strings only. You are passing productcode = 4 so when you put the &#039 in the query it is expecting a string and you are providing a number.

Posting Permissions

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