|
-
January 7th, 2000, 02:54 PM
#1
Retrieving from text file
set db = opendatabase("c:\directoryname",flase,false,"text")
set rs = db.openrecordset("filename",dbopendynaset)
do until rs.eof
msgbox rs(0)&rs(1)
rs.movenext
loop
it prints for rs(0) but gives error for rs(1)
the data i have in my file is in this order
ABC
XYZ
it prints only XYZ if i just ask it to print rs(0) and NOT ABC why?
What should i do such that both are printed.
-
January 7th, 2000, 03:21 PM
#2
Re: Retrieving from text file
You're making a couple of mistakes here..
You stated your file is in the Format:
In reply to:
ABC
XYZ
Therefore, there is only 1 Field, hence rs(1) gives an error as it referes to Field 2
Secondly, the First "Record" is treated as the Column/Field Headers, which is why you don't get to see ABC, you'll find it if you look under rs(0).Name Which is the Field Header.
Try this:
private Sub Command1_Click()
Dim oDB as Database
Dim oRS as Recordset
set oDB = OpenDatabase("C:\", false, false, "Text")
set oRS = oDB.OpenRecordset("File.txt", dbOpenDynaset)
Caption = oRS(0).Name
While Not oRS.EOF
List1.AddItem oRS(0)
oRS.MoveNext
Wend
oRS.Close
oDB.Close
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|