p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 12th, 2004, 11:59 AM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 12th, 2004, 04:04 PM
Friend of Wrox
Points: 4,754, Level: 29
Points: 4,754, Level: 29 Points: 4,754, Level: 29 Points: 4,754, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 13th, 2004, 04:14 AM
Authorized User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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");

%>;););)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 13th, 2004, 05:54 AM
Friend of Wrox
Points: 1,222, Level: 13
Points: 1,222, Level: 13 Points: 1,222, Level: 13 Points: 1,222, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2004
Location: Rawalpindi, , Pakistan.
Posts: 322
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

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 !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 13th, 2004, 08:39 AM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old July 13th, 2004, 10:17 AM
Friend of Wrox
Points: 1,879, Level: 17
Points: 1,879, Level: 17 Points: 1,879, Level: 17 Points: 1,879, Level: 17
Activity: 34%
Activity: 34% Activity: 34% Activity: 34%
 
Join Date: May 2004
Location: India
Posts: 562
Thanks: 0
Thanked 14 Times in 14 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old July 13th, 2004, 10:24 AM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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);


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old July 13th, 2004, 10:25 AM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But i have no idea what it could be

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #9 (permalink)  
Old July 13th, 2004, 10:56 AM
Friend of Wrox
Points: 2,801, Level: 22
Points: 2,801, Level: 22 Points: 2,801, Level: 22 Points: 2,801, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

<><
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #10 (permalink)  
Old July 13th, 2004, 11:41 AM
Authorized User
Points: 35, Level: 1
Points: 35, Level: 1 Points: 35, Level: 1 Points: 35, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The qoutes didn't change anything. Here is the print out:

INSERT INTO OrderItem (OrderNo, StockId, QtyOrdered) VALUES (18,,1)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED HELP INSERT INTO statement syntax error koco ASP.NET 1.0 and 1.1 Basics 6 June 2nd, 2006 05:01 PM
Syntax error in INSERT INTO statement mega ASP.NET 1.0 and 1.1 Basics 3 January 12th, 2005 04:30 PM
Syntax error in INSERT INTO statement evol77 ASP.NET 1.1 2 December 17th, 2004 06:15 AM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 01:21 AM
Syntax error in INSERT INTO statement sankar ASP.NET 1.1 9 May 20th, 2004 03:48 PM



All times are GMT -4. The time now is 07:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc