How do I read and update DbaseIII files.

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hi, the problem I have is that an older dos program is using dbase 3 or 4
database files and I wish to add a little utility that scanns this database,
and if specific record has a certain entry (flag) i wish to extract all of
the records for this entry change the flag in the dbase file and write it
into a new mdb database. The second part is no problem, i can hook into mdb
databases and do all that stuff, but I cannot seem to create a proper
connection with a dbase file.

Problem: How do I set a connection corectly with a sample.dpf sample.ndx,
and read and write records into this dataset.

Any help would be great
 
Hi,

It has been a while since I opened a dbase file. You do it the same
as with access but use this as the connection string
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= directory with dbase files;
Extended Properties=DBase III;". To open sample.dpf use this as your sql
statement. Select * from sample. Hope this helps.

Ken
 
I can import a dBase 5 table to a datatable in a dataset.
No idea if this works for older versions.

===========================================================
strSQL = "SELECT * FROM [" & dBaseTableName & "]"
If strFileFormat = "dBase 5.0" Then
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath &
";Extended Properties=""dBase 5.0"""
End If

Dim obj As New DAL(strConn)
obj.FillTable(dsMain, strTableName, strSQL, "OLEDB")
===========================================================
In my DAL (data access layer) I have a FillTable method:
===========================================================
Public Sub FillTable(ByRef ds As DataSet, ByVal TableName As String, ByVal
strSQL As String, ByVal DBtype As String)
If DBtype = "SQL Server" Then
'do something
ElseIf DBtype = "Oracle" Then
'do something
ElseIf DBtype = "OLEDB" Then
Dim da As OleDbDataAdapter
Dim cnn As New OleDbConnection(mConnStr)
Dim cmd As New OleDbCommand(strSQL, cnn)
Try
cmd.CommandType = CommandType.Text
cnn.Open()
da = New OleDbDataAdapter(cmd)
da.Fill(ds, TableName)
Catch exc As Exception
Throw exc
Finally
cnn.Close()
End Try
End If
End Sub
===========================================================
 
Hi Frank,

You can access dbase files as datatables etc just as any other ado .net
object if you use the odbc provider for .net. If you have vs .net 2003 you
have it and need only set the correct import statements; if an earlier
version, you can download it and install it from msdn.microsoft.com.

HTH,

Bernie Yaeger
 
Back
Top