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 - <html>
-
-
<head>
-
<style>
-
body{background: white)
-
</style>
-
<link rel="stylesheet" type="text/css" href="Main.css">
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
<title>Our Products</title>
-
</head>
-
-
<body>
-
<%
-
if request.cookies("UserName")="" then
-
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>")
-
else
-
Dim Conn, Rs, sql
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Set Rs = Server.CreateObject("ADODB.Recordset")
-
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("HeyPesto.mdb")
-
sql= "SELECT * FROM tblproducts;"
-
Rs.Open sql, Conn
-
-
dim index, order
-
index = 1
-
order = ""
-
-
-
do While not Rs.EOF
-
If request.form("amount" & index) > 0 Then
-
order = order & request.cookies("UserName") & Rs("name") & request.form("amount" & index)
-
end if
-
-
Rs.MoveNext
-
index = index + 1
-
loop
-
-
-
Response.Write(order)
-
-
-
Dim connorder, strConnorder, Rsorder
-
Set connorder = Server.CreateObject("ADODB.Connection")
-
strConnorder = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
-
"Data Source=" & Server.MapPath("HeyPesto.mdb") & "; " & _
-
"User ID=; Password="
-
connorder.Open strConnorder
-
Set Rsorder = connorder.Execute ("INSERT INTO tblorder(username,order) VALUES (" & request.cookies("UserName") & "','" & order & "')" )
-
-
Rs.Close
-
-
Set Rs = Nothing
-
Set Conn = Nothing
-
-
Rsorder.Close
-
-
Set Rsorder = Nothing
-
Set Connorder = Nothing
-
end if
-
%>
-
-
</body>
-
-
</html>
5 1742 jhardman 3,406
Recognized Expert Specialist
you are missing a single quote mark: - Set Rsorder = connorder.Execute ("INSERT INTO tblorder(username,order) VALUES ('" & request.cookies("UserName") & "','" & order & "')" )
Please let me know if this helps.
Jared
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
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.
Turns out 'order' requires square brackets when it is a field name.
Thanks a lot for your input, it works fine now.
NDayave
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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:
|
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 .
|
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?
|
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...
| |
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?
|
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:
|
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?
|
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.
|
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...
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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();...
| |
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
|
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...
| |