Solved

Dbase 4 access?

Posted on 2000-05-12
6
360 Views
Last Modified: 2013-11-24
Hi!

How can i open an existing DBase 4 Database (dallg1.dbf)?

How can i read and write Recordsets?

Thanks in advanced

Pierre
0
Comment
Question by:Falke
  • 2
  • 2
  • 2
6 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 2803738
This is one way to open a dBase IV table using the Microsoft Visual Foxpro Driver in code. You will need a reference to ADO in your project. You can then manipulate the ADO recordset in the normal way, using .Addnew /.Update etc to add records.

Dim cnnDBase As New Connection
Dim rstDBF As New Recordset
cnnDBase.ConnectionString = "Driver={Microsoft Visual Foxpro Driver};UID=;PWD=;SourceDB=C:\Private\;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
cnnDBase.Open
rstDBF.Open "SELECT * FROM <Table>",cnnDBase, adOpenDynamic, adLockOptimistic
With rstDBF
  msgbox .recordcount
  msgbox .fields(0).name & " : " & .fields(0).value
  .AddNew
  .fields(0).Value = "Hello"
  .Update
End With
rstDBF.Close
cnnDBase.Close
Set rstDBF = Nothing
Set cnnDBase = Nothing
0
 

Expert Comment

by:Alexander_Simons
ID: 2804117
Create a new .mdb file, link the dbase4 table you want to use

Now you can perform read/write/delete actions to the dbase4 tables by just  using simple dao functions from vb to access the .mdb file !
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 2804135
Alexander, I see that you are new here. I am happy to welcome you to this site and hope that you find much here useful. Also that you will be able to contribute much in the future.

However, it is considered bad practice to lock a question by posting an answer, see guidelines on http://www.experts-exchange.com/info/expertonly.html
especially when a satisfactory comment has already been posted. You give very little detail in your "Answer". Whilst using an access mdb is in some cases an acceptable technique, and DAO is a perfectly valid data access methodology.

The user may not wish to include the Jet engine and other components in the application. This adds a significant overhead to the footprint of the installed application and doesn't add anything over and above the functionality available using my method. Furthermore DAO will become obsolete in the future as Microsoft is likely to concentrate much more on the ADO technology as used in my example.

I would ask that you withdraw your "answer", feel free to add additional comments to this and other threads.

Falke:

Should Alexander_Simons not withdraw his answer I would suggest that you reject it and ask for more information should my comment not be sufficient for you.


0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Expert Comment

by:Alexander_Simons
ID: 2804708
Alexander_Simons changed the proposed answer to a comment
0
 

Author Comment

by:Falke
ID: 2806456
Your Code TimCottee doesn't work.

I have tried in another way, by using DATA objects, but if i run this code, it return an error
that the file doesn't exist, but it exist. In designermode i can do all perfectly, but in runtime
it occured always an error. (I am using DAO 3.6).

Maybe there is another option? I have to export data's into a DBF for older Programms,
maybe you know how i can make a DBF and make fields and insert data (it would be also possibility).



Data1.DatabaseName = "D:\Export\Kallg1.dbf"
Data1.Connect = "dBASE IV;"
Data1.RecordSource = "SELECT * FROM [KALLG1]"
Data1.Refresh
MsgBox Data1.Recordset.RecordCount
MsgBox Data1.Recordset.Fields(0).Name & " : " & Data1.Recordset.Fields(0).Value
0
 

Author Comment

by:Falke
ID: 2832766
You have not said something about

ADODBC reference, with ADO 3.6 it doesn't work. First i have to remove reference to ADO 3.6 so the NEW statment works.

Thanks a lot.....

Falke
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question