|
-
Oct 31st, 1999, 04:57 AM
#1
Thread Starter
New Member
My question is
How can i open a text file with ADO
and if i want some specific line in the text file to be displayed in a textbox, would i be able to do that??
-
Nov 1st, 1999, 09:49 PM
#2
Lively Member
Create your ADO Recordset in VB and then populate it with the text file data using a Loop and the "Input #filenumber, varlist" Statement.
In order to display a specific line in a text box, you can use a counter variable with the ADO recordset and loop through it in order to locate the line you are looking for. Populate the text box after the specific line has been found.
If you want the data in the ADO recordset to replace your original text file, use a Loop and the "Write # Statement" that points to the original file.
All the best.
[This message has been edited by ChrisJackson (edited 11-02-1999).]
-
Nov 4th, 1999, 12:06 PM
#3
New Member
'=========================================================================================
'Here are the steps to access a Text Files using ADO's
'Create a Text File Type DSN Using the ODBC
'Type the following code in Visual Basic. Make sure the reference is set for ADO library.
'=========================================================================================
Dim ladorec As New ADODB.Recordset
Dim ladoCon As New ADODB.Connection
Private Sub Form_Load()
'=========================================================================================
'Suppose you name the
'DSN As TEXTDSN
'And the Text File is named as a.txt
'The format of Text File is as Below
'Name Address Telephone
'A XYZ 1234567
'B X12 1234567
'C Z12 1234567
'=========================================================================================
ladoCon.Open "DSN=TEXTDSN"
Set ladorec = ladoCon.Execute("Select name,address,telephone from a.txt")
While Not ladorec.EOF
If ladorec("name") = "A" then
Text1.Text = ladorec("A")
Endif
ladorec.MoveNext
Wend
End Sub
'=========================================================================================
'Get back for any further clarification
'=========================================================================================
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
|