Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting info in database using subroutine

Status
Not open for further replies.

cic

Technical User
Apr 12, 2001
28
US
created a site that allows a user to purchase as many books as the want. after they order a book i would like to input their information into a database. i was told to use a procedure or a subroutine to do this, but i am not sure i fully understand how to go about doing this.

this is what i have started:

Sub insertDBinfo
SQL = "INSERT INTO publicationNW
(date,publication,quantity,price,freight,total,cardnumber,ag
entnumber,lastname,firstname,birthmonth,birthdate,birthyear,
address,state,zip) values (" &_
+ "getdate(),"&_
+ "'" & Desc1 & "',"&_
+ "'" & qty1 & "',"&_
+ "'" & request.form("price") & "',"&_
+ "'" & request.form("freight") & "',"&_
+ "'" & total1 & "',"&_
+ "'" & right(request.form("cardNum"),4) & "',"&_
+ "'" & request.form("agentnum") & "',"&_
+ "'" & request.form("lastname") & "',"&_
+ "'" & request.form("firstname") & "',"&_
+ "'" & request.form("DOBmonth") & "',"&_
+ "'" & request.form("DOBday") & "',"&_
+ "'" & request.form("DOByear") & "',"&_
+ "'" & request.form("address") & "',"&_
+ "'" & request.form("state") & "',"&_
+ "'" & request.form("zip")& "')"

oConn.execute SQL, ,adExecuteNoRecords
End Sub

desc1 is a book but how do i go about inserting the rest of the books without writing a subroutine for each one.
 
Yeah, you have to do a INSERT INTO for each record you want to add to a table. That's how databases work.

There are bulk operations but they are not relevant to your post.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top