Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cannot open *.CSV as ADO Recordset
Message
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00409913
Message ID:
00410811
Vues:
25
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform