在查询中添加WHERE子句时VB6 ADO错误

时间:2015-02-02 04:57:18

标签: sql csv vb6 ado

我有一个包含以下信息的csv文件:

NOMBRE,EDAD,FECHA
MARIO,30,24/12/2002
MARIA,90,24/12/2001
PEDRO,10,24/12/2004

然后我想使用这样的ADO与它进行交互:

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

有效!返回:

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

但是如果我尝试这样的查询:

SELECT EDAD FROM datos.csv WHERE NOMBRE='MARIO'

我有以下错误:

-2147467259 (800040005) Error in 'Execute' method of '_Connection' object.

我解雇的是什么?我唯一做的就是添加一个'其中'查询中的子句......

0 个答案:

没有答案