This sample demonstrates how to export data table into dbf file.
The picture above represents using Excel application to open the result dbf file.
private void btnDBF_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection oleDbConnection1
= new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString
= @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\Database\demo.mdb";
System.Data.OleDb.OleDbCommand oleDbCommand1
= new System.Data.OleDb.OleDbCommand();
oleDbCommand1.CommandText = "select * from parts";
oleDbCommand1.Connection = oleDbConnection1;
Spire.DataExport.DBF.DBFExport dbfExport1
= new Spire.DataExport.DBF.DBFExport();
dbfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
dbfExport1.FileName = "sample.dbf";
dbfExport1.SQLCommand = oleDbCommand1;
oleDbConnection1.Open();
dbfExport1.SaveToFile();
}
Private Sub btnDBF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDBF.Click
Dim oleDbConnection1 As New System.Data.OleDb.OleDbConnection()
oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\Database\demo.mdb"
Dim oleDbCommand1 As New System.Data.OleDb.OleDbCommand()
oleDbCommand1.CommandText = "select * from parts"
oleDbCommand1.Connection = oleDbConnection1
Dim dbfExport1 As New Spire.DataExport.DBF.DBFExport()
dbfExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
dbfExport1.FileName = "sample.dbf"
dbfExport1.SQLCommand = oleDbCommand1
oleDbConnection1.Open()
dbfExport1.SaveToFile()
End Sub