ADO and Delimited Text

N

Necromis

Below is my code I copied from another area and modified just as a
test to spit the info to a listbox. However, what I am trying to
accomplish is to store the data into variables so that I can use it
later with SendMessage and WM_SETTEXT. Can anyone offer how to tweek
this to make that happen. Thanks.

On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H1
Dim objConnection As Object
Dim objRecordset As Object
Dim strPathToTextFile As String
Dim strFileName As String

objConnection = CreateObject("ADODB.Connection")
objRecordSet = CreateObject("ADODB.Recordset")

strPathToTextFile = "F:\"
strFileName = infileBox.Text

objConnection.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended
Properties=""text;HDR=YES;FMT=Delimited""")

objRecordset.Open("SELECT * " & strFileName & "", _
objConnection, adOpenStatic, adLockOptimistic,
adCmdText)

Do Until objRecordset.EOF
ListBox1.Items.Add("Acctno: " &
objRecordset.Fields.Item("Acctno"))
ListBox1.Items.Add("expiration Date: " & _
objRecordset.Fields.Item("expirdte"))
ListBox1.Items.Add("First Name: " &
objRecordset.Fields.Item("name1"))
ListBox1.Items.Add("Last Name: " &
objRecordset.Fields.Item("name2"))
objRecordset.MoveNext()
Loop


End Sub
 
C

Cor Ligthert [MVP]

Necromis

I think that you will have more change in the newsgroup
microsoft.public.VB.general.discussion.

Your code will probably compile under VB.Net however for the rest it is
classic VB in my opinion.

We use by instance ADONET.
We use try and catch blocks to catch errors
I don't think that there are much with option strict and option explicit off

Cor
 
N

Necromis

Well I am trying to code in VB.net. However this was modified from
copied code so might not be completely accurate for VB.net. The jist
of what I'm trying to accomplish should still be clear. So correction
from classic VB to .net would be fine as far as I am concerned. I am
just trying to understand why the code is not processing any data into
the listbox and how I can correct that.
 

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

Top