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!

Using a text file as a record set

Status
Not open for further replies.

egolds

MIS
Aug 29, 2001
105
US
Hi all
I am working on a page to create an e-mail form. I would like to populate the who to send to dropdown box from a text file or some source that I can just upload to our hosting site every week or so rather than modify the select dropdowns everytime an employee leaves or we hire one.

I would like the file to be able to have Names and e-mail addresses (one for the value one for the display).

I am well versed in creating record sets from databases for applications I have created locally but since this is going to be hosted there will not be a database at the hosting site. I realize I could build an access database with one table with two columns and work that way but there must be an easier way.

Any ideas would be appreciated.
 
Use FSO put the contents into an array
Assuming this is a comma delimited file

strPath = Server.MapPath("yourfile.txt")
Set objFSO = CreateObject("Scripting.fileSystemObject")
Set objTextStream = objFso_OpenTextfile(strPath)

MyArray = Split(objTextStream.readall,",")




 
So set up the text file as:

John Smith,jsmith@company.com
Mary Jones,mjones@company.com
 
In that case slightly different

strPath = Server.MapPath("email.txt")
Set objFSO = CreateObject("Scripting.fileSystemObject")
Set objTextStream = objFso_OpenTextfile(strPath)

dim myarr(100,2)
counter=1

Do While objTextStream.AtEndOfStream <> True
tempmyArr= split(objTextStream.Readline, &quot;,&quot;)
myarr(counter,0)=tempmyarr(0)
myarr(counter,1)=tempmyarr(1)
counter=counter+1
Loop


for count=1 to counter
response.write myarr(count,0)
response.write myarr(count,1) & &quot;<BR>&quot;
next



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top