Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA & ADO - retreiving data from Approach dBase IV .dbf files

Hi folks,
I'm trying to send persuade Excel to send queries (SQL) to an approac
dBase IV (.dbf) file.

I've got these connection methods (courtesy of one of the tips here
which allows me to connect to another .xls file in the same way, but m
attempts to modify it so that I can query the dbf have so far bee
unsuccessful. What's the equivalent code to achieve what I'm trying t
do?

Sub openCN(cn As ADODB.Connection)
' open connection and leave open
Set cn = New ADODB.Connection
cn.Open "DRIVER={Microsoft Excel Drive
(*.xls)};DriverId=790;ReadOnly=True;" & _
"DBQ=" & datafile & ";" ' DriverId=790: Excel 97/2000
End Sub

Sub openRS(strSQL As String, cn As ADODB.Connection, rs A
ADODB.Recordset)
'open recordset and leave cn,rs open

On Error GoTo errhand
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Exit Sub

'error handling
errhand:
MsgBox "Error in openRS." & vbCr & vbCr & _
"SQL:" & strSQL
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA & ADO - retreiving data from Approach dBase IV .dbf files

You just need a different connection string

Sub openCN(cn As ADODB.Connection)
' open connection and leave open
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=c:\somepath"

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"EddyT " wrote in message
...
Hi folks,
I'm trying to send persuade Excel to send queries (SQL) to an approach
dBase IV (.dbf) file.

I've got these connection methods (courtesy of one of the tips here)
which allows me to connect to another .xls file in the same way, but my
attempts to modify it so that I can query the dbf have so far been
unsuccessful. What's the equivalent code to achieve what I'm trying to
do?

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

Sub openRS(strSQL As String, cn As ADODB.Connection, rs As
ADODB.Recordset)
'open recordset and leave cn,rs open

On Error GoTo errhand
Set rs = New ADODB.Recordset
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
Exit Sub

'error handling
errhand:
MsgBox "Error in openRS." & vbCr & vbCr & _
"SQL:" & strSQL
End Sub


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving dbase III Files using Office 2007 Bruce[_3_] Excel Discussion (Misc queries) 2 February 15th 08 09:21 PM
How can I save excel files to a DBASE format in excel 2007? ukag2007 Excel Discussion (Misc queries) 4 June 22nd 07 01:31 PM
How do I save DBase IV files in Excel 7.0? Kmontgo Excel Discussion (Misc queries) 7 April 11th 07 03:52 AM
How do I export Lotus Approach files into an Excel spreadsheet? LEWOLF New Users to Excel 1 March 20th 06 05:19 PM
Retreiving data from Excel spreadsheet through ADODB Roel Excel Programming 2 March 3rd 04 05:01 PM


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"