473,785 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL refuses to believe it works

92 New Member
How Do,

I have a rather simple website, which has some SQL embedded in the ASP to write user data to the underlying mdb database.

The first SQL statement looks up all the records in the database to help produce the required output which is a single string value which is the Customer's Order to be made in store for pickup. The second is to write the string into the database, and keeps shouting about a syntax error in the INSERT INTO statement. I however, cannot for the life of me find one.

I am more than aware that this is very poorly written and has absolutely no security features etc but they aren't necessary at the moment. All I need to know is how to get the Order in to the Database.

It is to be written to 'tblorder' into the fields 'username' and 'order' - both of which are text fields.

The database is properly shared and can be written to elsewhere on the site. The username comes from the username that is stored in the cookie 'UserName' and the product name from the recordset through indexing.

The String value is generated correctly, it just won't insert into the database.


Many Thanks,


NDayave


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <style>
  5. body{background: white)
  6. </style>
  7. <link rel="stylesheet" type="text/css" href="Main.css">
  8. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  9. <title>Our Products</title>
  10. </head>
  11.  
  12. <body>
  13. <%
  14. if request.cookies("UserName")="" then
  15.     response.write("<P align='Center'>You must be logged in to order from this page, please click <a target=Main href=login.asp>here</a> to log in, or click<a target=Main href=new_user.asp> here </a> if you are new to this site.</P>")
  16. else
  17. Dim Conn, Rs, sql
  18. Set Conn = Server.CreateObject("ADODB.Connection")
  19. Set Rs = Server.CreateObject("ADODB.Recordset")
  20. Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("HeyPesto.mdb")
  21. sql= "SELECT * FROM tblproducts;"
  22. Rs.Open sql, Conn
  23.  
  24. dim index, order
  25. index = 1
  26. order = ""
  27.  
  28.  
  29. do While not Rs.EOF
  30. If request.form("amount" & index) > 0 Then
  31.     order = order & request.cookies("UserName") & Rs("name") & request.form("amount" & index)
  32. end if
  33.  
  34. Rs.MoveNext
  35. index = index + 1
  36. loop
  37.  
  38.  
  39. Response.Write(order)
  40.  
  41.  
  42. Dim connorder, strConnorder, Rsorder
  43. Set connorder = Server.CreateObject("ADODB.Connection")
  44. strConnorder = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
  45. "Data Source=" & Server.MapPath("HeyPesto.mdb") & "; " & _
  46. "User ID=; Password="
  47. connorder.Open strConnorder
  48. Set Rsorder = connorder.Execute ("INSERT INTO tblorder(username,order) VALUES (" & request.cookies("UserName") & "','" & order & "')" )
  49.  
  50. Rs.Close
  51.  
  52. Set Rs = Nothing
  53. Set Conn = Nothing
  54.  
  55. Rsorder.Close
  56.  
  57. Set Rsorder = Nothing
  58. Set Connorder = Nothing
  59. end if
  60. %>
  61.  
  62. </body>
  63.  
  64. </html>
Mar 24 '09 #1
5 1742
jhardman
3,406 Recognized Expert Specialist
you are missing a single quote mark:
Expand|Select|Wrap|Line Numbers
  1. Set Rsorder = connorder.Execute ("INSERT INTO tblorder(username,order) VALUES ('" & request.cookies("UserName") & "','" & order & "')" )
Please let me know if this helps.

Jared
Mar 26 '09 #2
NDayave
92 New Member
Thanks for the suggestion.

Still throwing up error messages though:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/Order.asp, line 49

NDayave
Mar 26 '09 #3
jhardman
3,406 Recognized Expert Specialist
in general, the best way to troubleshoot sql is to response.write the sql statement, then plug it in to a query analyzer. Did you say you were using sql server? there should be an analyzer built in to the management studio.
Mar 26 '09 #4
NDayave
92 New Member
Turns out 'order' requires square brackets when it is a field name.

Thanks a lot for your input, it works fine now.

NDayave
Mar 26 '09 #5
jhardman
3,406 Recognized Expert Specialist
Ah yes, "order" is a sql reserved word. Any field name can be put in square brackets without bothering SQL, so some people do it always, the rest should make sure they never use reserved words (or words with reserved characters) for field names.
Mar 27 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
2366
by: lkrubner | last post by:
We are working on a website that is here: http://www.lauradenyes.com/ The site was working till I put up an .htaccess file that was suppose to redirect all html files to the PHP parser. The site then stopped working, because I had the address of the PHP parser wrong. I then deleted the .htaccess file, and the site began to work again. However, on one machine it still does not work in FireFox.
0
1315
by: Wayne Aprato | last post by:
Can anyone please help me with the following madness in Access 2003 (2000 file format). I am using 2 similar funtions, the first which works fine to save reports as snapshots: On Error Resume Next DoCmd.OutputTo A_REPORT, Forms!FrontPage!RptName, "Snapshot Format (*.snp)", , False and the second which is giving me the problem, to email reports as snapshots:
1
1844
by: Ebrahim | last post by:
This message is in reply to a prev 1 . My application refues to close . Some one had suggested that I might have threads running.. but i solved that problem too . The app still refuses to close . !! Here is the code for one of them !! I call a stop function to disconnect all objects (close ) . I also make a call to Stop in the Dispose() function .
2
1234
by: Beeeeeves | last post by:
Why whenever I create a project in c#, when I compile it, it has got the resulting executable TWICE in TWO different directories - obj\debug and bin\debug. WHY? Sometimes when I'm trying to debug it, when I press F5 the one that's running is obviously not the same one to the one that i've just made changes to, as it doesn't seem to update my changes. Why does it do this stupid behaviour?
7
2017
by: Daniel | last post by:
I have an winform application that uses System.IO.StreamReader and Serializer.Deserialize to load some data from a file, if any error is detected in the file a new file should be written to the same directory, I use a StreamWriter and Serializer.Serialize to do this. The problem is that when the streamreader has opened the file it does not release it until the application is closed. When I try to use the StreamWriter to write the new...
3
9013
by: Glen Parker | last post by:
First things first: Postgresql 8.4.2 on Fedora Core 2 X86. Something seems to have happened to my pg_xlog and pg_clog directories after (I believe) a power outage. In the course of trying to figure out why the server wouldn't start, I cleaned out pg_clog and pg_xlog, in an obviously vain attempt to reset things. I was under the impression that the server could start without those files. Now I seem to be stuck. So now what?
1
2009
by: ticmanis | last post by:
Hello, I'm having trouble getting MSIE 6.0 (running on XP SP2) to accept a cookie which works fine in both Firefox and wget. The web server is Boa 0.94.13 (a small embedded server) using PHP 4.3.10 for CGI. Even with the lowest security settings in MSIE there is no cookie acceptance, and no "Cookie:" HTTP header is being sent back by MSIE. This is the php code for a fairly minimal testcase:
3
1157
by: RadhikaG | last post by:
my dropdownlist_selectedindexchange method just refuses to get invoked when i switch from any value in the dropdown list to the default value. why??? how do i get it work for this as well?
12
4258
by: Rainer Queck | last post by:
Hi NG, I have no idea why, but since a while a dataset refuses to write to a specific xml file. I get the error message "Der Zugriff auf den Pfad D:\VS2005Projects\BfpNet\BfpNet\bin\Debug\Bfp.xml wurde verweigert" which translates to: "The access to the path D:\VS...... was denied". The dataset can read from this Bfp.xml without any problems.
2
2973
tpgames
by: tpgames | last post by:
Two days ago, MS office Word would type JP fonts, I thought. I didn't think I was using Works. Now, it won't type in JP. Jasc Paint shop pro 8, should type JP fonts because I am using XP, according to Corel's website, and Jasc uses whatever is in the XP font folder. But, it won't. All the JP fonts types as English, even with JP selected in the Language Bar. I can't afford to upgrade to any better paint program. I do have a free JP word...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.