Hi folks,
I'm trying to persuade Excel to send queries (SQL) to an approach dBase IV (.dbf) file. I've been wrestling with this for a while now, and haven't had any success.
I'm trying to modify the below method (which allows me to connect to another .xls file in the desired manner), but my attempts to modify it so that I can query the dbf have so far been unsuccessful.
Quote:
quote:Sub openCN(cn As ADODB.Connection)
' open connection and leave open
Set cn = New ADODB.Connection
cn.Open "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;ReadOnly=True;" & _
"DBQ=" & datafile & ";" ' DriverId=790: Excel 97/2000
End Sub
|
So far so good. However... if I try
Quote:
quote:
Sub openDbfCN(cn As ADODB.Connection)
'open connection to dbf and leave open
Set cn = New ADODB.Connection
cn.Open "DRIVER={Microsoft dBase Driver (*.dbf)};ReadOnly=True;" & _
"DBQ=" & dbffile & ";"
End Sub
|
then I end up with "[Microsoft][ODBC dBase Driver]General error Unable to open registry key âTemporary (volatile) Jet DSN for process 0x1c0 Thread 0x4c0 DBC 0xd7d0064 Xbaseâ."
Also, if I try
Quote:
quote:
Dim filedlg As FileDialog
Set filedlg = Application.FileDialog(msoFileDialogOpen)
filedlg.Title = "Please select the desired database"
If filedlg.Show <> -1 Then Exit Sub 'user clicked cancel
dbffile = filedlg.SelectedItems(1)
'create the connection string
szconnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & dbffile & ";" & _
"Extended Properties=dBase IV;"
Set objConn = New ADODB.Connection
objConn.Open szconnect
|
It tells me the path is invalid, which leaves me even more confused.
Any help would be much appreciated.
Ed.
Ne auderis delere orbem rigidum meum!