connecting a dBase III - Database using Ado 
Author Message
 connecting a dBase III - Database using Ado

Hello,

I can't find any information about dBase III-connections with ADO.
I know the use of ODBC-connections, but I can't use them for this
project. Does anyone know a way to connect to a .dbf-file ?

Thank you!
--
Peter Elsen



Sat, 23 Aug 2003 22:50:19 GMT  
 connecting a dBase III - Database using Ado
Try this...

The following example creates a DSN-Less connection using a VFP Free Table
ODBC Connection string.

Public Function ConString_VFP_FT(ByVal Source As String) As String
  Const cnnstr1 As String = "Provider=MSDASQL.1;Persist Security
Info=False;Extended Properties=""DSN=Visual FoxPro Tables;UID=;SourceDB="
  Const cnnstr2 As String =
";SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=No;De
leted=No;"""

  ConString_VFP_FT = cnnstr1 & Source & cnnstr2
End Function

Private Sub YourSub()
  Dim rst as adodb.recordset
  Dim sSQL as string

  sSQL = "SELECT YourFields FROM TableName"

  Set rst = New ADODB.Recordset
  With rst
    .ActiveConnection = ConString_VFP_FT(Directory_of_DBF_File)
    .Source = sSQL
    .Open Options:=adCmdText
  End With

  rst.close
  set rst = nothing
End Sub


Quote:
> Hello,

> I can't find any information about dBase III-connections with ADO.
> I know the use of ODBC-connections, but I can't use them for this
> project. Does anyone know a way to connect to a .dbf-file ?

> Thank you!
> --
> Peter Elsen



Sun, 24 Aug 2003 03:34:59 GMT  
 connecting a dBase III - Database using Ado

'dbase Connection
With DBFcn
    .Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=dBASE Files;Initial Catalog=" & {Directory Name ("C:\DATA\")}
End With

'dbase Recordset
With DBFrs
    .ActiveConnection = DBFcn
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .Open "Select * FROM [" & {FILENAME ("DATAFILE.DBF")} & "]"
    .MoveFirst
    Do While Not .EOF
        .MoveNext
    Loop
    .Close
End With

Quote:

> Hello,

> I can't find any information about dBase III-connections with ADO.
> I know the use of ODBC-connections, but I can't use them for this
> project. Does anyone know a way to connect to a .dbf-file ?

> Thank you!
> --
> Peter Elsen



Sun, 24 Aug 2003 23:43:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ADO problem with database operations on dBase III tables

2. ADO problem with database operations on dBase III tables

3. ISAM error using dBASE III database

4. connecting to dBase III dbf table with VB 6

5. Connect VB6 to dBase III file

6. ADO connection string for Dbase III file (*.dbf)

7. Attaching a dBase III table to Access 2000 via ADO

8. ADO/ADOX dBASE III connection/catalog issue...

9. Import dBase III files to Access 2000 with ADO

10. Selecting from dBase - ISAM III, with ADO

11. ADO link dBASE III table syntax

12. open dbase type dbase III

 

 
Powered by phpBB® Forum Software