SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

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 January 13th, 2004, 11:30 AM
tcampb tcampb is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 tcampb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Insert into syntax

Can any of you SQL gurus see a problem here? It seems no matter how I change the syntax of the INSERT, I get either a syntax error or expected end of statement error.
Please help this rookie.
TIA
Tom C

PS. this is inserting into an Access DB

<%
brokerage = Request.form("Brokerage")
broker_phone = Request.form("Broker_phone")
agent = Request.form("agent")
agent_phone = Request.form("agent_phone")
agent_cell = Request.form("agent_cell")
agent_email = Request.form("agent_email")
mris = Request.form("mris")
pay_type = Request.form("pay_type")
cc_no = Request.form("cc_no")
cc_type = Request.form("cc_type")
cc_exp = Request.form("cc_exp")
cc_ccv = Request.form("ccv")
address = Request.form("address")
city = Request.form("city")
state = Request.form("state")
zip = Request.form("zip")
level = Request.form("level")
cust_provision = Request.form("cust_provision")
initial_setup = Request.form("initial_setup")
post_color = Request.form("post_color")
cust_notes = Request.form("cust_notes")
%>



<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "e:\web\selectsignp\htdocs\_database\db1.mdb"

conn.execute INSERT INTO Create_acct (brokerage, broker_phone, agent, agent_phone, agent_cell, agent_email, MRIS, pay_type, cc_type, cc_no, cc_exp, cc_ccv, address, city, state, zip, level, cust_provision, initial_setup, post_color, Cust_notes) VALUES ('"&brokerage&"','"&broker_phone&"','"&agent&"','"&agent_phone&"','"&agent_cell&"','"&agent_email&"','"&mris&"','"&pay_type&"','"&cc_type&"','"&cc_no&"','"&cc_exp&"','"&cc_ccv&"','"&address&"','"&city&"','"&state&"','"&zip&"','"&level&"','"&cust_provision&"','"&initial_setup&"','"&post_color&"','"&cust_notes&"')

conn.close
%>

Reply With Quote
  #2  
Old January 13th, 2004, 11:56 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
Provided that all your fields are text data types, I don't think the problem is you Statement, it is the way you are using it.

I believe that you need "around the whole statement"

conn.execute "INSERT INTO Create_acct (brokerage, broker_phone, agent, agent_phone, agent_cell, agent_email, MRIS, pay_type, cc_type, cc_no, cc_exp, cc_ccv, address, city, state, zip, level, cust_provision, initial_setup, post_color, Cust_notes) VALUES ('"&brokerage&"','"&broker_phone&"','"&agent&"','"&agent_phone&"','"&agent_cell&"','"&agent_email&"','"&mris&"','"&pay_type&"','"&cc_type&"','"&cc_no&"','"&cc_exp&"','"&cc_ccv&"','"&address&"','"&city&"','"&state&"','"&zip&"','"&level&"','"&cust_provision&"','"&initial_setup&"','"&post_color&"','"&cust_notes&"')"

S-

Reply With Quote
  #3  
Old January 13th, 2004, 10:11 PM
tcampb tcampb is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 2 tcampb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your quick reply.

Tried all sorts of quote, parenthesis combinations.
Your suggestion returned the following:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/ssp/register.asp, line 41

conn.execute INSERT INTO Create_acct (brokerage, ....
--------------------^

This shouldn't be this troublesome. I have several other pages selecting from DB with no problems. I double checked the field types in the DB and they are in fact all text.

Any other suggestions?
Tom C

Reply With Quote
  #4  
Old February 3rd, 2004, 07:21 PM
GenkiDave's Avatar
GenkiDave GenkiDave is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Canada
Posts: 60 GenkiDave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Just a piece of advice that I found very useful.

I would Dim a recordset and an SQL statment, use the recordset variable to equal the SQL statment, THEN execute the rs statement. I found that it's a lot more organized when I review the code.

Example:

Dim rs, strSQL

Set adoConn = Server.CreateObject("ADODB.Connection")

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=db1.mdb" & ";" & _
"Persist Security Info=False"
adoConn.Open(sConnection)


strSQL = "INSERT INTO Create_acct (brokerage, broker_phone, agent, agent_phone, agent_cell, agent_email, MRIS, pay_type, cc_type, cc_no, cc_exp, cc_ccv, address, city, state, zip, level, cust_provision, initial_setup, post_color, Cust_notes) VALUES ('"&brokerage&"','"&broker_phone&"','"&agent&"','"&agent_phone&"','"&agent_cell&"','"&agent_email&"','"&mris&"','"&pay_type&"','"&cc_type&"','"&cc_no&"','"&cc_exp&"','"&cc_ccv&"','"&address&"','"&city&"','"&state&"','"&zip&"','"&level&"','"&cust_provision&"','"&initial_setup&"','"&post_color&"','"&cust_notes&"')"

Set rs = adoConn.Execute(strSQL)

//////All of your other code here///////////////



Set rs = nothing
adoConn.close
Set adoConn = nothing

It looks a lot nicer and easy to read, but hey, that's only my opinion...

Reply With Quote
  #5  
Old February 3rd, 2004, 07:30 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 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 8 h 45 m 55 sec
Reputation Power: 470
Quote:
Originally posted by GenkiDave
Just a piece of advice that I found very useful.

I would Dim a recordset and an SQL statment, use the recordset variable to equal the SQL statment


You don't need a recordset when running an insert, update or delete statement, since no records are going to be returned. You only need to use a recordset object when data is going to be returned from the query.

it should be
Code:
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "e:\web\selectsignp\htdocs\_database\db1.mdb"

conn.execute("INSERT INTO Create_acct (brokerage, broker_phone, agent, agent_phone, agent_cell, agent_email, MRIS, pay_type, cc_type, cc_no, cc_exp, cc_ccv, address, city, state, zip, level, cust_provision, initial_setup, post_color, Cust_notes) VALUES ('"&brokerage&"','"&broker_phone&"','"&agent&"','"&agent_phone&"','"&agent_cell&"','"&agent_email&"','"&mris&"','"&pay_type&"','"&cc_type&"','"&cc_no&"','"&cc_exp&"','"&cc_ccv&"','"&address&"','"&city&"','"&state&"','"&zip&"','"&level&"','"&cust_provision&"','"&initial_setup&"','"&post_color&"','"&cust_notes&"')")

conn.close

or
Code:
sql = "INSERT INTO Create_acct (brokerage, broker_phone, agent, agent_phone, agent_cell, agent_email, MRIS, pay_type, cc_type, cc_no, cc_exp, cc_ccv, address, city, state, zip, level, cust_provision, initial_setup, post_color, Cust_notes) VALUES ('"&brokerage&"','"&broker_phone&"','"&agent&"','"&agent_phone&"','"&agent_cell&"','"&agent_email&"','"&mris&"','"&pay_type&"','"&cc_type&"','"&cc_no&"','"&cc_exp&"','"&cc_ccv&"','"&address&"','"&city&"','"&state&"','"&zip&"','"&level&"','"&cust_provision&"','"&initial_setup&"','"&post_color&"','"&cust_notes&"')"

Conn.Execute(sql)

Reply With Quote
  #6  
Old February 4th, 2004, 12:02 AM
GenkiDave's Avatar
GenkiDave GenkiDave is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Canada
Posts: 60 GenkiDave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Well, I was close

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Insert into syntax


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 4 hosted by Hostway
Stay green...Green IT