|
|
 |
BOOK: Beginning JavaScript  | This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning JavaScript section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

July 12th, 2004, 11:59 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Syntax error in INSERT INTO statement
Hi,
I am currently working on chapter 16. I have created the database and the relevant asp pages. However, when i submit my name, address and telephone number in the AddOrderDetails form i get the following error message:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/test_database/AddOrderDetails.asp, line 41
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Page:
POST 94 bytes to /test_database/AddOrderDetails.asp
POST Data:
txtStockId=&txtCustomerName=test&txtCustomerAddres s=test&txtTelNumber=23232&submit1=Send+Order
Time:
12 July 2004, 16:54:22
I have double checked the spelling of each field name and they are all correct. Any Ideas?
|

July 12th, 2004, 04:04 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hello,
[
That's a SQL error, so I will have to see the statement to make a suggestion. In addition, if you do a:
Response.Write(strSQL)
Response.End
before you execute it, you can see what the error may be in the SQL.
Brian
|

July 13th, 2004, 04:14 AM
|
|
Authorized User
|
|
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi stephan here is some code that i have been working on works fine for me.
hope it helps !javascript:insertsmilie(';)')
Wink ;)
<%@LANGUAGE="JAVASCRIPT"%>
<%
// getting values from previous form
var sn,fn,surn,a1,a2,a3,ext,mobile,email,dob;
sn = Request.Form("staffNumber");
fn = Request.Form("firstname");
surn = Request.Form("surname");
a1 = Request.Form("address1");
a2 = Request.Form("address2");
a3 = Request.Form("address3");
ext = Request.Form("extn");
mobile = Request.Form("mobile");
email = Request.Form("email");
dob = Request.Form("day1") +"/"+Request.Form("month1")+"/"+Request.Form("year1");
adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("DSN=input");
var SQL = "INSERT INTO tblStaff (staffID,firstname,surname,DateOfBirth,address1,ad dress2,address3,extn,mobile,email)";
SQL = SQL + "VALUES("+sn+",'"+fn+"','"+surn+"','"+dob+"','"+a1 +"','"+a2+"','"+a3+"',"+ext+","+mobile+",'"+email+ "')";
adoConnection.Execute(SQL);
adoConnection.Close();
adoConnection = null;
Response.Redirect("part1done.asp");
%>;););)
|

July 13th, 2004, 05:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2004
Location: Rawalpindi, , Pakistan.
Posts: 322
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dear Stephan can you post the code here. And one thing that you should post your problem on right topic
Numan
--------------------------------------------------
Love is the most beautiful thing of this world. So do this !
|

July 13th, 2004, 08:39 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the code
<%@ language = JavaScript%>
<html>
<head>
</head>
<body>
<%
var month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var nowDate = new Date();
var nowDate = nowDate.getDate() + " " + month[nowDate.getMonth()] + " " + nowDate.getFullYear();
var orderNo;
var adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("DSN=ComBitsCoDB");
var adoRecordset;
var 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;
var 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 was completed successfully" + "</center></h2>");
%>
</body>
</html>
|

July 13th, 2004, 10:17 AM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Location: India
Posts: 562
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
I think the problem is with date in the following statement:
mySQL = mySQL + " VALUES ('" + Request.Form("txtCustomerName") + "','";
mySQL = mySQL + Request.Form("txtCustomerAddress") + "','";
mySQL = mySQL + Request.Form("txtTelNumber") + "','";
mySQL = mySQL + nowDate + "')";
Om Prakash
|

July 13th, 2004, 10:24 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I beleive the error is in the following section, well i think that's where the error message is pointing to:
r mySQL = "INSERT INTO OrderItem (OrderNo, StockId, QtyOrdered)";
mySQL = mySQL + " VALUES (" + orderNo + ",";
mySQL = mySQL + Request.Form("txtStockId") + ",";
mySQL = mySQL + "1)";
adoConnection.Execute(mySQL);
|

July 13th, 2004, 10:25 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
But i have no idea what it could be
|

July 13th, 2004, 10:56 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try printing out what mySQL is, and comment out the line that executes it.
Also, could it be that you didn't quote the '1' at the end of the statement?
HTH,
Snib
<><
|

July 13th, 2004, 11:41 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The qoutes didn't change anything. Here is the print out:
INSERT INTO OrderItem (OrderNo, StockId, QtyOrdered) VALUES (18,,1)
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |