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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding multiples to SQL db dynamically

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Greetings,

I have a registration database that adds members to a members database then to a registration database. There are 8 possible registrants. My questions is, how can I do this dynamcially without having eight different SQL statements? Here's the code. It's all very clunky and cumbersome, but I don't know how to do it any other way:
(strLName could be strLName 1 through 8)

strSQL = "insert into members (MemPrcID,MemLastName,MemFirstName,MemMI,MemAddr1,MemAddr2,MemCity,MemState,MemZip,MemPhone,MemFax,MemEmail) values('" & strPrcID & "','" & strLName & "','" & strFName & "','" & strMI & "','" & strAddr1 & "','" & strAddr2 & "','" & strCity & "','" & strState & "','" & strZip & "','" & strPhone & "','" & strFax & "','" & strEmail & "')"
objConn.Execute(strSQL)
strSQL2 = "Select * from members where MemPrcID = '" & strPrcID & "' and MemLastName= '" & strLName & "'"
objConn.Execute(strSQL2)
Set oRs2 = objConn.Execute(strSQL2)
strMemID=oRs2("MemID")
strSQL3 = "insert into registrations (RegPrcID,RegMemID,RegPrgID,RegFeeCharged,RegSource,RegBillToID) values('" & strPrcID & "','" & strMemID & "','" & strPrgID & "','" & strPrgFee & "','9','" & strPrcID & "')"
objConn.Execute(strSQL3)

Any thoughts or suggestions would be greatly appreciated. Thank you very much.
 
I'm not certain I understand this question, but here goes. Make the strName assignment prior to the sql statements, use a select conditional test block to assign the actual value to strName. eg:

'# use the appropriate test here
IF strName1 <> &quot;&quot; THEN
strName = strName1
ELSEIF strName2 <> &quot;&quot; THEN
and so on
END IF

HTH
 
Thanks GearHead,

This will work just fine.

Mel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top