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

loading a recordset from textfile

Status
Not open for further replies.

jimny

Technical User
Oct 18, 2002
52
US
I am trying to create a recordset from a textfile.

I have imported and seperated the records in the text file:

Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("penny.txt"), 1)
do while f.AtEndOfStream = false
ad= f.ReadLine


I have set the recordset object(I need the paging ability)

set rsAD = server.CreateObject("ADODB.RecordSet")
rsAD.PageSize = PAGE_SIZE
rsAD.CacheSize = PAGE_SIZE
rsAD.Open ?????, connTEMP, adOpenStatic, adLockReadOnly, adCmdText
recCntr = rsAD.RecordCount
pgCnt = rsAD.PageCount


I just don't know how to get each line of the text file in to the recordset. Can you point me in the right direction?

thanks
 
jimny,

You don't state it, but imply that this will be displayed in a web page.

If that is the case, you are then looking at using .ASP and have ODBC and ADO available.

If your using ASP and since you have posted this on the VBScript forum we can make a leap in logic that your running this on an NT or 2000 machine.

That being the case, check out:

ODBC Driver for Text at:

Provides a sample of the connect string for a text file.

Also, suggest checking MS site for details on using Text as source at:

Sample on ADO Recordset Paging...

I could be wrong, but I would believe you have to use ADO to read the data into the recordset. Assumes you have a definite field separator, and the above articles deal with that.

Then the ADO Recordset Paging example should cover the remaining points.

Hope this helps.
DougCranston
 
dilettante,

I tried searching, including the FAQ's and I did not come up with this. Would not have pointed jimny off TekTips otherwise.

Thanks,
DougCranston
 
Yeah, I can't wait until they get the searches upgraded here on Tek-Tips. I know they have some changes in the works here, but I'm not sure how close they are to reality.

Search improvements will make things much easier for everyone.
 
DougCranston & Dilettante,
thanks for the replies. You are correct about it being an ASP page, MY BAD!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top