Nige_S4
10-16-2003, 08:22 PM
Hello, I am getting the above error and can't figure out what I am doing wrong. The page reads field names from an access Db and allows you to update the field values & pressing submit writes them back to the Db.
Here is the related part of the code;
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Request("Submit") <> "" Then
varProdIDs = Replace(Request("hidProdIDs"), "*", "") ' remove all the asterisks, to create a list like this: 2, 5, 8, 9 etc.
varRecArray = Split(varProdIDs, ", ") ' Create an array, wich will contain just the IDs of the records we need to update
For i = 0 to Ubound(varRecArray) ' Loop through the array
%>
<%
if(Request("Delivery" & varRecArray(i)) <> "") then commUpdate__varNum1 = Request("Delivery" & varRecArray(i))
if(Request("Price" & varRecArray(i)) <> "") then commUpdate__varNum = Request("Price" & varRecArray(i))
if(Request("Stock" & varRecArray(i)) <> "") then commUpdate__varNum2 = Request("Stock" & varRecArray(i))
if(Request("hidProdID" & varRecArray(i)) <> "") then commUpdate__varProdID = Request("hidProdID" & varRecArray(i))
%>
<%
set commUpdate = Server.CreateObject("ADODB.Command")
commUpdate.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("MyData.mdb") & ";Persist Security Info=False"
commUpdate.CommandText = "UPDATE TestTable SET Price = '" + Replace(commUpdate__varNum, "'", "''") + "', Stock = '" + Replace(commUpdate__varNum2, "'", "''") + "', Delivery = " + Replace(commUpdate__varNum1, "'", "''") + " WHERE ProdID = " + Replace(commUpdate__varProdID, "'", "''") + ""
commUpdate.CommandType = 1
commUpdate.CommandTimeout = 0
commUpdate.Prepared = true
commUpdate.Execute()
%>
Here is the error code ;
Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.
/adm1n/Update.asp, line 25
Interestingly, if I delete the 'Stock' entry, the script works OK ?
Any ideas ?
Here is the related part of the code;
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Request("Submit") <> "" Then
varProdIDs = Replace(Request("hidProdIDs"), "*", "") ' remove all the asterisks, to create a list like this: 2, 5, 8, 9 etc.
varRecArray = Split(varProdIDs, ", ") ' Create an array, wich will contain just the IDs of the records we need to update
For i = 0 to Ubound(varRecArray) ' Loop through the array
%>
<%
if(Request("Delivery" & varRecArray(i)) <> "") then commUpdate__varNum1 = Request("Delivery" & varRecArray(i))
if(Request("Price" & varRecArray(i)) <> "") then commUpdate__varNum = Request("Price" & varRecArray(i))
if(Request("Stock" & varRecArray(i)) <> "") then commUpdate__varNum2 = Request("Stock" & varRecArray(i))
if(Request("hidProdID" & varRecArray(i)) <> "") then commUpdate__varProdID = Request("hidProdID" & varRecArray(i))
%>
<%
set commUpdate = Server.CreateObject("ADODB.Command")
commUpdate.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("MyData.mdb") & ";Persist Security Info=False"
commUpdate.CommandText = "UPDATE TestTable SET Price = '" + Replace(commUpdate__varNum, "'", "''") + "', Stock = '" + Replace(commUpdate__varNum2, "'", "''") + "', Delivery = " + Replace(commUpdate__varNum1, "'", "''") + " WHERE ProdID = " + Replace(commUpdate__varProdID, "'", "''") + ""
commUpdate.CommandType = 1
commUpdate.CommandTimeout = 0
commUpdate.Prepared = true
commUpdate.Execute()
%>
Here is the error code ;
Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.
/adm1n/Update.asp, line 25
Interestingly, if I delete the 'Stock' entry, the script works OK ?
Any ideas ?