|
少し変えてみましたが、エラーです
Public Sub Get_Csv1()
Dim csvPath As String
Dim csvFilename As String
csvPath = CurrentProject.Path & "\;"
csvFilename = "20081219152808DL_AssetData.csv"
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & csvPath & _
"Extended Properties=""Text;FMT=Delimited;HDR=yes;"""
cnn.Open
Set rst = New ADODB.Recordset
rst.Open "select * from " & csvFilename, cnn, adOpenForwardOnly, adLockOptimistic
'↑動きます
'rst.Open "select * from" & csvFilename & " where [F0str] = '001', cnn, adOpenForwardOnly, adLockOptimistic"
'↑実行時エラー '3709':この操作を実行するために接続を使用できません。このコンテキストで閉じているかあるいは無効です。
While rst.EOF = False
Debug.Print rst(0).Value & "," & rst(1).Value & "," & rst(2).Value
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
cnn.Close
Set cnn = Nothing
End Sub
|
|