[RESOLVED] Instead fox pro driver for dbf...
I tested a DBF connection in vba with the code above...
Work fine...
But instead to use Fox Pro driver is possible to open dbf datadase with a standard driver installed to the default in win2000?
My dubt is:
"if the machine where i run the code not have installed the Fox Pro driver" ????
Code:
Option Explicit
Dim fld As ADODB.Field, TEST As String
Dim FXPConn As New ADODB.Connection, DBFQuantity As Double
Dim FXPRs As New ADODB.Recordset, CONTA As Long, ULTIMA As Long
Dim FXPDBSQL As String, DATI As Variant, intRecord
Dim DBFileName As String, PathDBFileName As String
Dim VAR1 As String, VAR2 As String, WS As Worksheet
Sub DBF_LOOP()
Set WS = Sheets("Foglio1")
CONTA = 2
DBFileName = "Gaf_arc.DBF"
'PathDBFileName = "\\gcd01f4500\dati\pubblica\antiric\"
PathDBFileName = "C:\EPF"
'FXPDBSQL = "SELECT DISTINCT PROVA01,PROVA02 FROM " & DBFileName & " ORDER BY PROVA01"
FXPDBSQL = "SELECT * FROM " & DBFileName & " "
'DBF
FXPConn.Open "Driver={Microsoft Visual FoxPro Driver};" & _
"SourceType=DBF;" & _
"SourceDB=" & PathDBFileName & ";" & _
"Exclusive=No"
'DBF
FXPRs.CursorLocation = adUseClient
FXPRs.Open FXPDBSQL, FXPConn, adOpenDynamic, adLockOptimistic, 1
'QUI PER SAPERE IL NOME DEI CAMPI ED ALTRE INFO
For Each fld In FXPRs.Fields
TEST = UCase(fld.Name)
TEST = fld.Type
TEST = fld.DefinedSize
Next
'QUI PER SAPERE IL NOME DEI CAMPI ED ALTRE INFO
DBFQuantity = FXPRs.RecordCount
ULTIMA = Sheets("Foglio1").Cells(65536, 1).End(xlUp).Row + 1
WS.Range("A2:B" & ULTIMA).ClearContents
'Call APRI_ACCESS
' con getrow e array
DATI = FXPRs.GetRows
CONTA = UBound(DATI, 2) + 1
FXPRs.Close
FXPConn.Close
CONTA = 2
With WS
For intRecord = 0 To UBound(DATI, 2) '+ 1
VAR1 = Trim(DATI(0, intRecord))
.Range("A" & CONTA) = VAR1
VAR2 = Trim(DATI(1, intRecord))
.Range("B" & CONTA) = VAR2
CONTA = CONTA + 1
Next intRecord
End With
'con getrow e array
FXPRs.MoveFirst
'normale NON CHIUDERE IL RECORDSET
While Not FXPRs.EOF
VAR1 = Trim(FXPRs(0))
'OPPURE
VAR2 = Trim(FXPRs(1))
'OPPURE
FXPRs.MoveNext
Wend
'normale NON CHIUDERE IL RECORDSET
FXPRs.Close
FXPConn.Close
'normale
End Sub