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

[Beginner Question] New recordset for each item in Array

Status
Not open for further replies.

a55m0nk

Programmer
Dec 23, 2003
4
GB
To whoever can give me a hand lol,

I am developing a messaging script, and i want to have the ability to sent to many users. After the form is submitted, i split the string up into an array (which i have done) and then a copy of the message has to be written to the DB for each element in the array. Here is the code:
-----------------------------------------------------
<%
dim msgSentTo, msgSubject, msgBody, msgPriority, msgSentFrom, msgDate, msgRead, arSentTo(*,1)
dim userMID, strUserConn, strUserSQL


================SEND A MESSAGE================
userMID = Session(&quot;userID&quot;)

strUserSQL = &quot;SELECT userName FROM tblUsers WHERE userID = &quot; & userMID & &quot;&quot;
set strUserConn = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
strUserConn.Open strUserSQL, &quot;camel&quot;, 3, 3

userName = strUserConn(&quot;userName&quot;)

strUserConn.close
set strUserConn = nothing

msgSentTo = Request.Form(&quot;msgSentTo&quot;)
msgSubject = Request.Form(&quot;msgSubject&quot;)
msgBody = Request.Form(&quot;msgBody&quot;)
msgPriority = 2
if InStr(&quot;msgSubject&quot;,&quot;~~~&quot;) then
msgPriority = 1
end if
msgSentFrom = userName
msgDate = time & &quot; &quot; & date
msgRead = False

arSentTo = Split(msgSentTo, &quot;,&quot;)
===[ THIS IS WHERE I GET STUCK]===

----------------------------------------------------

Any help would be greatly appriciated.
many thanks
a55m0nk
 
You need a new set of SQL to insert your data into the appropriate table. Check out the Insert and/or Insert Into SQL statements. Then you spin through your array like so:

For lngX = 0 To UBound(arSentTo) 'Arrays are zero based
strTemp = arSentTo(lngX)
'Do your SQLInsert code here using strTemp
Next lngX

Hope this helps and good luck!

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top