View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jean-Yves[_2_] Jean-Yves[_2_] is offline
external usenet poster
 
Posts: 253
Default use ADO invoking dbf file in excel

Hi,

Here is some sample code for an access DB
If you use f1 on some word like recorset you should get explanation from the
help file.

Sub showAdo()
'you have too make a reference via tools: Micrsoft ActiveX data Object 2.1

Dim cnObject As ADODB.Connection
Dim rec1 As ADODB.Recordset
Dim x As Integer, temp As String
Dim strPath As String
strPath = ThisWorkbook.Path

Set cnObject = New ADODB.Connection
Set rsObject1 = New ADODB.Recordset

cnObject.Open "Provider= Microsoft.Jet.OLEDB.4.0;" & "Data Source = " &
strPath & "\YourdataBase.mdb;"
rec1.Open "Select * from Your_Table ;", cnObject, adOpenForwardOnly,
adLockOptimistic

Do While rsObject1.EOF = False
For x = 4 To rec1.Fields.Count - 1
Debug.Print rec1.Fields(x).Name
If InStr(rec1.Fields(x).Value, vbLf) < 0 Then
Debug.Assert rec2.Fields(x).Value
End If
Next
rec1.MoveNext
Loop

rsObject1.Close
cnObject.Close
End Sub

Regards,
Jean-Yves


"hedia.ccf" wrote in message
...
how to use ADO invoking dbf file in excel,thus ,I hope to know more about

ADO