Results 1 to 11 of 11

Thread: [RESOLVED] VB6 ADO error when adding WHERE clause in query

Threaded View

  1. #1

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Resolved [RESOLVED] VB6 ADO error when adding WHERE clause in query

    I have a csv file with the following information:

    Code:
    NOMBRE,EDAD,FECHA
    MARIO,30,24/12/2002
    MARIA,90,24/12/2001
    PEDRO,10,24/12/2004
    Then I want to interact with it using ADO like this (I've added Microsoft ActiveX Data Objects 2.0 Library reference):

    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
    It works! Returns:

    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
    But If I try to do a query like this:

    Code:
    SELECT EDAD FROM datos.csv WHERE NOMBRE='MARIO'
    I have the following error:

    Code:
    -2147467259 (800040005) Error in 'Execute' method of '_Connection' object.
    What am I dismissing? The only thing I've done is adding a 'where' clause in the query...
    If I compile the code, the same error appears:

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width