Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Add more than 1 record at once ?

Reply
Thread Tools

Add more than 1 record at once ?

 
 
David
Guest
Posts: n/a
 
      01-05-2004
Hi,

Quick question.

I have a form on an asp page which is used to add additional users to
the DB, i.e. adding a UserID (PK on table), Password & Email.

The companies are allowed a max of 3 users. If the company only has
the default 1 user and wishes to add another 1 or 2, then the form
displays the current user details, not in text boxes as this is not an
adit data form. The additional user/s can be entered into 1/2 rows of
text boxes, user 2 & 3.

If they decide to add 2 new users, how do I add the additional 2
records to my db table on submit ?

I am using a MySQL DB.


This is the code I have from an update form which can edit the default
user.
How can I change this code to add the 2 new records ?

___________________________________________

<%

vUser = request.form("user")
vPass = request.form("pass")
vEmail = request.form("email")

uSQL = "UPDATE OrderStatusAccess SET "
uSQL = uSQL & "UserID= '" & vUser & "'"
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"
uSQL = uSQL & " WHERE CustomerID='" & session("customer") & "';"

Set RS = adoDataConn.Execute(uSQL)
%>
__________________________________________________ ________


Thanks for your help


David
 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      01-05-2004
David wrote:
> Hi,
>
> Quick question.
>
> I have a form on an asp page which is used to add additional users to
> the DB, i.e. adding a UserID (PK on table), Password & Email.
>
> The companies are allowed a max of 3 users. If the company only has
> the default 1 user and wishes to add another 1 or 2, then the form
> displays the current user details, not in text boxes as this is not an
> adit data form. The additional user/s can be entered into 1/2 rows of
> text boxes, user 2 & 3.
>
> If they decide to add 2 new users, how do I add the additional 2
> records to my db table on submit ?
>
> I am using a MySQL DB.
>
>
> This is the code I have from an update form which can edit the default
> user.
> How can I change this code to add the 2 new records ?
>
> ___________________________________________
>
> <%
>
> vUser = request.form("user")
> vPass = request.form("pass")
> vEmail = request.form("email")
>
> uSQL = "UPDATE OrderStatusAccess SET "
> uSQL = uSQL & "UserID= '" & vUser & "'"
> uSQL = uSQL & ", Password = '" & vPass & "' "
> uSQL = uSQL & ", Email ='" & vEmail & "'"
> uSQL = uSQL & " WHERE CustomerID='" & session("customer") & "';"
>
> Set RS = adoDataConn.Execute(uSQL)


Why "Set RS"??? This query is not returning a record! Why force ADO to go to
the time and trouble of creating a recordset object that will simply be
discarded? Do this instead:

adoDataConn.Execute uSQL,,129

(129 is the addition of two constants: adCmdText (1) and adExecuteNoRecords
(12 - your queries will execute more efficiently if you specify the
commandtype and execution options instead of making ADO guess)

> %>
> __________________________________________________ ________
>
>
> Thanks for your help
>
>
> David


Create 2 INSERT statements using the passed values and execute them as
above.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
 
David Gordon
Guest
Posts: n/a
 
      01-05-2004

Thanks Bob,

I have this code:

_________________________________________

for i = 1 to 2 (either 1 or 2 records added)

vUser = request.form("user")
vPass = request.form("pass")
vEmail = request.form("email")

uSQL = "INSERT into OrderStatusAccess "
uSQL = uSQL & "UserID= '" & vUser & "'"
uSQL = uSQL & ", Password = '" & vPass & "' "
uSQL = uSQL & ", Email ='" & vEmail & "'"

uSQL = uSQL & " WHERE CustomerID='" & session("customer") & "';"

adoDataConn.Execute uSQL,,129

next

___________________________________________

How do I adjust this code to accept the multiple records from the form ?

I get the following error:

SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'UserID= '', Password = '' , Email ='' WHERE CustomerID='20'' at


Thanks
David


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      01-05-2004
An INSERT statement looks like this:

INSERT tablename(columnname, columnname) VALUES('value', 'value')

There is no columnname = value syntax in an INSERT.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"David Gordon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Thanks Bob,
>
> I have this code:
>
> _________________________________________
>
> for i = 1 to 2 (either 1 or 2 records added)
>
> vUser = request.form("user")
> vPass = request.form("pass")
> vEmail = request.form("email")
>
> uSQL = "INSERT into OrderStatusAccess "
> uSQL = uSQL & "UserID= '" & vUser & "'"
> uSQL = uSQL & ", Password = '" & vPass & "' "
> uSQL = uSQL & ", Email ='" & vEmail & "'"
>
> uSQL = uSQL & " WHERE CustomerID='" & session("customer") & "';"
>
> adoDataConn.Execute uSQL,,129
>
> next
>
> ___________________________________________
>
> How do I adjust this code to accept the multiple records from the form ?
>
> I get the following error:
>
> SQLState: 42000
> Native Error Code: 1064
> [TCX][MyODBC]You have an error in your SQL syntax. Check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near 'UserID= '', Password = '' , Email ='' WHERE CustomerID='20'' at
>
>
> Thanks
> David
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com Java 0 03-06-2008 08:11 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
You cannot add or change a record because a related record is required in table 'lok" André ASP .Net 0 06-25-2006 01:30 PM
Regex to match say char 't' exactly once in a string and no more than once Gancy Perl Misc 4 02-03-2005 02:19 PM



Advertisments