Read from text area

M

Mark Fisher

Hi

I have a database on a website, and a table in this db contains two fields,
PCode, and Verified. I have to add new records to this in batches, and
these batches are generated on a local PC.

Is it possible to paste the contents of a text file into a text area form
field, and then run an asp/vbscript routine to update the database.

The text file contents to be pasted would be in the format:

1234, Y
1235, N
1236, Y

I am ok with updating the database, what I would like to know is how to
split the text into individual items - is there some kind of read line
function.

Thanks
 
S

Scott McNair

Is it possible to paste the contents of a text file into a text area
form field, and then run an asp/vbscript routine to update the
database.

Set Cn = Server.CreateObject("ADODB.Connection")
Cn.ConnectionString = "[...]"
RowArray = Split(Request.Form("MyTextBox"),vbcrlf)
For Each Item In RowArray
Cn.Execute "Insert Into MyTable (Field1, Field2) Values '" & Trim(Split
(Item,",")(0)) & "', '" & Trim(Split(Item,",")(1)) & "'"
Next
Set Cn = Nothing

Untested code, but it should work for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top