I have a csv file with the following information:
Then I want to interact with it using ADO like this (I've added Microsoft ActiveX Data Objects 2.0 Library reference):Code:NOMBRE,EDAD,FECHA MARIO,30,24/12/2002 MARIA,90,24/12/2001 PEDRO,10,24/12/2004
It works! Returns:Code:Dim oConn As New ADODB.Connection Dim oRS As New ADODB.Recordset oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=" & Environ("temp") & ";" _ & "Extended Properties=""text;HDR=Yes;FMT=Delimited(,)"";Persist Security Info=False" Set oRS = oConn.Execute("select * from datos.csv") Dim ofield As ADODB.Field Do Until oRS.EOF For Each ofield In oRS.Fields Debug.Print "Field Name = " & ofield.Name & " Field Value = " & ofield.Value Next ofield oRS.MoveNext Loop
But If I try to do a query like this:Code:Field Name = NOMBRE Field Value = MARIO Field Name = EDAD Field Value = 30 Field Name = FECHA Field Value = 24/12/2002 Field Name = NOMBRE Field Value = MARIA Field Name = EDAD Field Value = 90 Field Name = FECHA Field Value = 24/12/2001 Field Name = NOMBRE Field Value = PEDRO Field Name = EDAD Field Value = 10 Field Name = FECHA Field Value = 24/12/2004
I have the following error:Code:SELECT EDAD FROM datos.csv WHERE NOMBRE='MARIO'
What am I dismissing? The only thing I've done is adding a 'where' clause in the query...Code:-2147467259 (800040005) Error in 'Execute' method of '_Connection' object.
If I compile the code, the same error appears:
![]()





Reply With Quote
