According to the source your connection string for the ADODB.CONNECTION should look something like this:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\FileServer01\Server VFTP Dynamic\Data;
Extended Properties=dBASE IV;User ID=Admin;Password=;
Your first (test) query could be
SELECT * FROM [a_sname.dbf]
In case of trouble, I'd
- map
\\FileServer01\Server VFTP Dynamic
to a drive letter, change the connection string accordingly and try again - use Data Sources to establish a connection interactively/with help of a GUI and use this experience to build the connection string
Added:
Some tested code to increase your confidence:
Option Explicit
Dim sDir : sDir = "\\gent\eh\...etc...\testdata\dbf"
Dim sCS : sCS = Join(Array( _
"Provider=Microsoft.Jet.OLEDB.4.0" _
, "Data Source=" & sDir _
, "Extended Properties=""dBASE IV;""" _
), ";")
Dim oCN : Set oCN = CreateObject("ADODB.CONNECTION")
oCN.Open sCS
Dim oRS : Set oRS = oCN.Execute("SELECT TOP 2 * FROM [tblAbles]")
Do Until oRS.EOF
WScript.Echo oRS.Fields(0).Name, oRS.Fields(0).Value
oRS.MoveNext
Loop
oCN.Close
output:
cscript 22934726.vbs
RTATID 2
RTATID 3
Troubleshooting I:
- In the code you published,
sDir
contains a file spec ("Z:\a_sname.dbf"), not a folder/directory spec - Windows ??, ?? Bit (do you need to work in a 32 Bit environment?)
- ADO Version?
WScript.Echo CreateObject("ADODB.Connection").Version
Troubleshooting II:
- Make sure a_sname.dbf is a valid .dbf (of version ?) by opening it using some other tool (Excel, Access, ODBC, ...)
- Tweak the "dBase IV" property
Troubleshooting III:
see here for getting the version from the file header
use a GUI (e.g. Data Sources) to find possible values for "dBase XX"
Troubleshooting (not dBase!) IV:
According to the source, you can/must(?) use a VFP specific connection string: maybe
Provider=vfpoledb;Data Source=C:\MyDataDirectory\;Collating Sequence=general;
Perhaps you need to download a provider DLL (be carefull wrt versions!)