Directory path problem opening *.DBF table in VBA via ADO 
Author Message
 Directory path problem opening *.DBF table in VBA via ADO

I open a *.DBF table (created with Visual FoxPro 6.0) in Excel using
VBA script with ADO. The syntax below works fine only if the directory
path does not contain "-" or " " characters. If it does, I get a
message "Invalid syntax in FROM clause". Can anybody suggest a way
around it?

I will appreciate if you could e-mail directly to

Thank you!

My code:

Global cnnDBF As New ADODB.Connection
Global rsDBF As New ADODB.Recordset

cnnDBF.Open "Providor=Microsoft.OLEDB; Data Source=dBASE Files;
Database=C:\MYPATH\MYFILE.DBF;"

rsDBF.Open "C:\MYPATH\MYFILE.DBF", cnnDBF, adOpenKeyset,
adLockOptimistic, adCmdTable



Tue, 14 Dec 2004 04:45:05 GMT  
 Directory path problem opening *.DBF table in VBA via ADO
Hi,

If you established connection properly, then I think you could read from
table using select statement, not path to file. Try to use next kind of code

rsDBF.Open "SELECT * FROM MYFILE.DBF", cnnDBF, adOpenKeyset,
 adLockOptimistic, adCmdText

--
Val Mazur
Microsoft MVP


Quote:
> I open a *.DBF table (created with Visual FoxPro 6.0) in Excel using
> VBA script with ADO. The syntax below works fine only if the directory
> path does not contain "-" or " " characters. If it does, I get a
> message "Invalid syntax in FROM clause". Can anybody suggest a way
> around it?

> I will appreciate if you could e-mail directly to

> Thank you!

> My code:

> Global cnnDBF As New ADODB.Connection
> Global rsDBF As New ADODB.Recordset

> cnnDBF.Open "Providor=Microsoft.OLEDB; Data Source=dBASE Files;
> Database=C:\MYPATH\MYFILE.DBF;"

> rsDBF.Open "C:\MYPATH\MYFILE.DBF", cnnDBF, adOpenKeyset,
> adLockOptimistic, adCmdTable



Tue, 14 Dec 2004 20:03:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Use Ado to open Foxpro 3.0 Dbf Table!!!

2. How to open free dbf table using ADO

3. problem updating page numbers after opening a file (all via VBA)

4. Create DBF via ADO?

5. Unable to open .dbf table

6. Opening a linked dbf table

7. Populate a table with the path and file from a directory

8. Linked picture - change path via VBA

9. ADO and dbf tables

10. Using ADO to open DBF in VB

11. Open file via UNC path

12. Open Foxpro dbc/dbf with ADO

 

 
Powered by phpBB® Forum Software