Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query Error

Status
Not open for further replies.

terawebwriter

Programmer
Nov 22, 2002
10
US
Can someone help me with this one please. Whatever I change the fields to, it wont work. ASP with MS Access Database. ReceivedProductsID is the Autonumber in MS Access Database where I create a link to edit the record #.

Error:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/Updates/UpdateHardware.asp, line 17

The ASP page sending the request. The page is basically a list of all records in the database with a link to ReceivedProductsID to click and edit that record. Code Below:
<%

Set RS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
SqlString = &quot;SELECT ReceivedProductsID, ProductName, UnitsOrdered, PO, Arrival, ReceivedBy, SerialNumber, Department, Requestor&quot;
SqlString = SqlString & &quot; FROM ReceivedProducts&quot;

Set RS = objConn.Execute ( SqlString )
%>


The ASP page receiving the request to update the record:
<%

recnum = Request.QueryString(&quot;recnum&quot;)

recnum = Trim(recnum)
Response.write (recnum)
sqlString2 = &quot;SELECT *&quot;
sqlString2 = sqlString2 & &quot; FROM ReceivedProducts&quot;
sqlString2 = sqlString2 & &quot; WHERE ReceivedProductsID = '&quot; & recnum & &quot;'&quot;

SET RS2 = objConn.Execute( sqlString2 )

%>

If I change this line --sqlString2 = sqlString2 & &quot; WHERE ReceivedProductsID = '&quot; & recnum & &quot;'&quot;-- to ReceivedProductsID = 6&quot;, it will return that record only no matter which link you click on, which is normal, so it looks like I have to specify the ID in order for it to work. ANY HELP I WOULD APPRECIATE VERY MUCH...
 
I may be barking up the wrong tree but I think ASP tends to treat varaibles as text unless otherise instructed and so you may need to convert you variable 'recnum' to an integer
e.g. cInt(recnum)

Andy
 
If ReceivedProductsID is a number field, you need to remove the single quotes that you have around the value in your sql string:

sqlString2 = &quot;SELECT *&quot;
sqlString2 = sqlString2 & &quot; FROM ReceivedProducts&quot;
sqlString2 = sqlString2 & &quot; WHERE ReceivedProductsID = &quot; & recnum
 
Sorry, but it still did not work. It gave me the same error. Basically I just want to get a list of records from the database (which works fine), list them, and than take the ID of each file and pass it to another page to edit that record (make changes to the record). Any help I would appreciate it very much...
 
JuanitaC......
THANK YOU VERY VERY MUCH. It worked. I thank you for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top