Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 11th, 2004, 09:38 PM
sk8ter04 sk8ter04 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 22 sk8ter04 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 40 sec
Reputation Power: 0
adding item to database

i was just wondering if someone could help me out and see whats wrong with this
code because i tryed to run it and it was giving me an error on the mySQL line
here is the code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<%
myDSN = "DBQ=" & server.MapPath("OnlineDatabase.mdb")& ";Driver={Microsoft Access Driver (*.mdb)};"
set Conn = server.CreateObject("ADODB.Connection")
mySQL = "Insert Into [ProductTable] ([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])
VALUES('"& Request.Form("Product Name") &"; Request.Form("Product Description") &"; Request.Form("Product Price") &"; Request.Form("Product Quantity") &"; Request.Form("Categoy ID") &"; Request.Form("Product Image") &"; Request.Form("Size");"
Conn.Open myDSN
Conn.Update mySQL
Conn.Close
Set conn = Nothing
%>
<body>
<p>Congratulations you have</p>
<p>successfuly added a new product</P>
</body>
</html>

if someone could get back to me with whats wrong with it.

this is the error message im getting when i try and run it




Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/submitadd.asp, line 11 mySQL = "Insert Into [ProductTable] ([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])

Reply With Quote
  #2  
Old May 11th, 2004, 09:48 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 7 h 8 m
Reputation Power: 469
If the data types are text (string), then surround the variables with single quotes ('). If their numbers don't surround them with single quotes.
Code:
VALUES('" & Request.Form("ProductName") & "', '" & Request.Form("ProductDescription") & "', '" & Request.Form("ProductPrice") & "', '" & Request.Form("ProductQuantity") & "', '" & Request.Form("CategoryID") & "', '" & Request.Form("ProductImage") & "', '" & Request.Form("Size") & "'"

Reply With Quote
  #3  
Old May 11th, 2004, 10:04 PM
sk8ter04 sk8ter04 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 22 sk8ter04 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 40 sec
Reputation Power: 0
error on mySQL line

mySQL = "Insert Into [ProductTable] ([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])



Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/submitadd.asp, line 11 mySQL = "Insert Into [ProductTable] ([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])that is the line and and error on that line and im not sure what is wrong with it

Reply With Quote
  #4  
Old May 11th, 2004, 10:08 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,770 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 7 h 8 m
Reputation Power: 469
Try my suggestion.

Reply With Quote
  #5  
Old May 11th, 2004, 10:13 PM
sk8ter04 sk8ter04 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 22 sk8ter04 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 40 sec
Reputation Power: 0
Quote:
Originally Posted by Memnoch
Try my suggestion.

i did the suggestion you told me about and im still getting that same error

Reply With Quote
  #6  
Old May 11th, 2004, 11:54 PM
HardCoder HardCoder is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 HardCoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow adding item to database

Try as coded below, don't use single quotes.
line 11 is not terminated, put a double quote at the end ... ,[Size])"
line 12 - remove the single quote ' at character 9
see below:


Code:
 
		  VALUES("& Request.Form("Product Name") &";
		  not 
		  VALUES('"& Request.Form("Product Name") &";
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<%
myDSN = "DBQ=" & server.MapPath("OnlineDatabase.mdb")& ";Driver={Microsoft Access Driver (*.mdb)};"
set Conn = server.CreateObject("ADODB.Connection")
mySQL = "Insert Into [ProductTable]" "([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])"
VALUES("& Request.Form("Product Name") &"; Request.Form("Product Description") &"; Request.Form("Product Price") &"; Request.Form("Product Quantity") &"; Request.Form("Categoy ID") &"; Request.Form("Product Image") &"; Request.Form("Size");"
Conn.Open myDSN
Conn.Update mySQL
Conn.Close
Set conn = Nothing
%>
<body>
<p>Congratulations you have</p>
<p>successfuly added a new product</P>
</body>
</html>

Reply With Quote
  #7  
Old May 12th, 2004, 12:42 AM
sk8ter04 sk8ter04 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 22 sk8ter04 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 40 sec
Reputation Power: 0
Quote:
Originally Posted by HardCoder
Try as coded below, don't use single quotes.
line 11 is not terminated, put a double quote at the end ... ,[Size])"
line 12 - remove the single quote ' at character 9
see below:


Code:
 
		  VALUES("& Request.Form("Product Name") &";
		  not 
		  VALUES('"& Request.Form("Product Name") &";
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<%
myDSN = "DBQ=" & server.MapPath("OnlineDatabase.mdb")& ";Driver={Microsoft Access Driver (*.mdb)};"
set Conn = server.CreateObject("ADODB.Connection")
mySQL = "Insert Into [ProductTable]" "([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])"
VALUES("& Request.Form("Product Name") &"; Request.Form("Product Description") &"; Request.Form("Product Price") &"; Request.Form("Product Quantity") &"; Request.Form("Categoy ID") &"; Request.Form("Product Image") &"; Request.Form("Size");"
Conn.Open myDSN
Conn.Update mySQL
Conn.Close
Set conn = Nothing
%>
<body>
<p>Congratulations you have</p>
<p>successfuly added a new product</P>
</body>
</html>

i did that change and i got this error now




Microsoft VBScript compilation error '800a03ee'

Expected ')'

/submitadd.asp, line 12 VALUES("& Request.Form("Product Name") &"; Request.Form("Product Description") &"; Request.Form("Product Price") &"; Request.Form("Product Quantity") &"; Request.Form("Categoy ID") &"; Request.Form("Product Image") &"; Request.Form("Size");"

Reply With Quote
  #8  
Old May 12th, 2004, 01:25 AM
HardCoder HardCoder is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 HardCoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes, there is much more going on with your code than i picked up on at first glance. try this below: using the codepage and vbscript header, save your page as an ASP file
If that doesn't work try a whole different approach as in option 2, making sure to rename your fields in the ASP file and in the access datbase "WITHOUT" the spaces.

Code:
  
<%@ LANGUAGE="VBScript" codepage="1252" %>
<%
myDSN = "DBQ=" & server.MapPath("OnlineDatabase.mdb")& ";Driver={Microsoft Access Driver (*.mdb)};"
set Conn = server.CreateObject("ADODB.Connection")
mySQL = "Insert Into [ProductTable]" & "([Product ID],[Product Name],[Product Description],[Product Price],[Product Quantity],[Category ID],[Product Image],[Size])"
 & "VALUES (" & Request.Form("Product Name")" & "Request.Form("Product Description")" & "Request.Form("Product Price")");"
Conn.Open myDSN
Conn.Update mySQL
Conn.Close
Set conn = Nothing
%>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<p>Congratulations you have</p>
<p>successfuly added a new product</P>
</body>
</html>
 
OPTION 2
 
Dim str ProductName
Dim str ProductDescription
.....ETC.
 
Function CheckStr(str)
 checkit = Replace(str,"'","''")
End Function
 
strProductName = Request.Form("ProductName")
strProductDescription = Request.Form("ProductDescription")
.....ETC.

ProductName = CheckStr(ProductName)
ProductDescription = CheckStr(ProductDescription)
.....ETC.
 
strSQL = "INSERT INTO ProductTable " _
  & "(ProductName, ProductDescription, ) " _
  & "VALUES (" & ProductName & ", '" _
  & ProductDescription & "', '" _

.....ETC.
 
  & ProductPrice & "');"   'NOTE CLOSING HERE, FOR LAST FIELD

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > adding item to database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT