I have already checked the following topic from Stephan -
http://p2p.wrox.com/topic.asp?TOPIC_...s=INSERT,error.
I am having similar problems but have not been able to correct the problem.
Unlike Stephan, I have connected to the database using a DSN-less connection and it seems to be working fine from the DisplayStock.asp page.
The BuyItem.asp page also seems to work. It is picking up the StockID passed thru the URL.
The error occurrs when trying to perform the INSERT INTO sql.
Here is the error I receive:
_______________________________________________
Technical Information (for support personnel)
Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.
/WROXDBSample/AddOrderDetails.asp, line 29
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)
Page:
POST 151 bytes to /WROXDBSample/AddOrderDetails.asp
POST Data:
txtStockID=5&txtCustomerName=Thomas+Seroogy&txtCus tomerAddress=201+Christa+Lane%2C+Nicholasville%2C+ KY+40356&txtTelNumber=8599835958&submit1=Send+Orde r
Time:
Friday, December 10, 2004, 8:34:15 AM
__________________________________________________ _______
my script for the AddOrderDetails.asp page are as follows:
Code:
<%@ LANGUAGE = JavaScript %>
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<%
var month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Nov", "Dec");
var nowDate = new Date();
var nowDate = nowDate.getDate() + " " + month[nowDate.getMonth()] + " " + nowDate.getFullYear();
var orderNo;
var myDb = "F:\\dB";
var adoRecordSet;
var mySQL;
var adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + myDb + "\\CompBitsCo.mdb");
mySQL = "INSERT INTO CustomerOrder(CustomerName, CustomerAddress, TelNumber, OrderDate)";
mySQL = mySQL + " VALUES('" + Request.Form("txtCustomerName") + "','";
mySQL = mySQL + Request.Form("txtCustomerAddress") + "','";
mySQL = mySQL + Request.Form("txtTelNumber") + "','";
mySQL = mySQL + nowDate + "')";
adoConnection.Execute(mySQL);
mySQL = "SELECT Max(OrderNo) AS MaxOrderNo FROM CustomerOrder WHERE ";
mySQL = mySQL + " OrderDate = #" + nowDate + "# AND ";
mySQL = mySQL + " CustomerName = '" + Request.Form("txtCustomerName") + "'";
adoRecordSet = adoConnection.Execute(mySQL);
orderNo = adoRecordSet("MaxOrderNo").Value;
adoRecordSet.Close();
adoRecordSet = null;
mySQL = "INSERT INTO OrderItem (OrderNo, StockID, QtyOrdered)";
mySQL = mySQL + " VALUES (" + orderNo + ",";
mySQL = mySQL + Request.Form("txtStockId") + ",";
mySQL = mySQL + "1)";
adoConnection.Execute(mySQL);
adoConnection.Close();
adoConnection= null;
Response.Write("<h2><center>Your order has completed successfully</center></h2>");
%>
</body>
</html>
Any help is appreciated.
Best regards,
sabertec2
PS - You can access all of the pages by going to
www.saber-tool.com/displaystock.asp