I use this code to read a txt file with ADO...
now i need to use a varible string instead [ZIPDD001.TXT]Code:Sub uno() Dim CN As ADODB.Connection, RS As ADODB.Recordset Dim TEST As String, I As Long Set CN = New ADODB.Connection CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\TEMP\;Extended Properties=""text;HDR=Yes;FMT=Delimited""" Set RS = New ADODB.Recordset RS.CursorLocation = adUseClient RS.Open "select * from [ZIPDD001.TXT]", CN, adOpenDynamic, adLockReadOnly, adCmdText While Not RS.EOF For I = 0 To RS.Fields.Count - 1 If Not IsNull(RS(I).Value) Then TEST = RS(I).Value End If Next I RS.MoveNext Wend End Sub
for example:
RS.Open "select * from [name of my var here]", CN, adOpenDynamic, adLockReadOnly, adCmdText
how to midifiy this conn?




Reply With Quote