Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot open *.CSV as ADO Recordset
Message
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00409913
Message ID:
00410811
Views:
26
>Use this:
>
>
Option Explicit
>
>Private oFileConn As ADODB.Connection
>Private oRS As ADODB.Recordset
>
>Private Function GetFileRS() As Recordset
>Dim msPath As String
>Dim msFile As String
>Dim msLine As String
>Dim i As Long
>
>    msPath = "c:\temp\"
>    msFile = "[test.csv]"
>    Set oFileConn = New Connection
>    With oFileConn
>        .Mode = adModeReadWrite
>        .CursorLocation = adUseClient
>        .Open "Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=" & _
>              msPath & ";DefaultDir=" & msPath & ";Uid=;Pwd=;"
>    End With
>    Set oRS = New Recordset
>    oRS.Open "select * from " & msFile, oFileConn
>    oRS.ActiveConnection = Nothing
>    Set GetFileRS = oRS
>End Function
>
>Private Sub Command1_Click()
>    Set DataGrid1.DataSource = GetFileRS
>End Sub
Thanks, that worked. I added the line:

msFile="[" & msFile & "]"
George
Previous
Reply
Map
View

Click here to load this message in the networking platform