WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2006, 04:22 PM
WebProWorld New Member
 

Join Date: Feb 2006
Posts: 12
jpdeveloper RepRank 0
Default Error inserting 40 rows into access database table at once?

I am continually getting the error:
[Microsoft][ODBC Microsoft Access Driver] Missing semicolon (;) at end of SQL statement.

I have a web based ASP web form which the user will enter a name and answer 40 questions then have those answers insert into an access database. I have my answer table setup as field names:
Name
answer_num
answer_a
answer_b
since there is two answer for each question.
I know how to insert into the table all as one row but I was getting errors when trying to pass a total of 40 rows at one time. I hard coded the answer number but wanted to grab the name entered and the two answer (A_1A-first answer for question1)&(A_1B-second answer for question1) that the user selected from the form.
This is a part of the insert that I have:

Code:
SQL = "insert into survey_answers (name, answer_num, answer_a, answer_b)"

SQL = SQL & "values ('" & Name & "', '1', '" & A_1A & "', '" & A_1B & "')"

SQL = SQL & "values ('" & Name & "', '2', '" & A_2A & "', '" & A_2B & "')"

 rs.Open sql, cn
Basically am I going about this all wrong, do I need to set up my table differently? Or is this even possible to do? Any input in this one?
Thanks in advance..really appreciate the advice on this one.
Reply With Quote
  #2 (permalink)  
Old 04-12-2006, 01:06 PM
WebProWorld Member
 

Join Date: Apr 2006
Posts: 31
sacx13 RepRank 0
Default

Try to do a loop and for each cycle do a insert in database
Code:
For(i=0;i<40;i++)
{
SQL = "insert into survey_answers (name, answer_num, answer_a, answer_b)"
SQL = SQL & "values ('" & Name & "', 'i', '" & A_iA & "', '" & A_iB & "')" 
rs.Open sql, cn 
}
here is just some "pseudo code" try to do that for you scripting langauge

Regards
Adrian
http://www.mydomaintracker.net
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags: , , , , , ,



Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0