'DBF/FoxPro Connection with VBA

i want to make a connection with a DBF file through VBA, i have installed all the drivers but i get this error message every time i try to run it

Object variable not set (Error 91)

Sub Teste()

Dim dbConn As OLEDBConnection

dbConn.ConnectionString = "Provider=vfpoledb;Data Source=" & "G:\Registros_Oficiais\Contabilidade\2022_01\ARREIDEN.DBF" & ";Extended Properties=dBASE IV;"

dbConn.Open
    
End Sub

Can someone help me? What am i missing?



Solution 1:[1]

Your connection string needs to point to the PATH where the data resides, not the specific table. So if your connection is to

"G:\Registros_Oficiais\Contabilidade\2022_01"

Your queries will just need to reference the tables such as

select * from SomeTable where...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DRapp