This sample demonstrates how to export data table into ms-access file.
The picture above represents using Excel application to open the result ms-access file.
private void btnMSAccess_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.Access.AccessExport accessExport1
= new Spire.DataExport.Access.AccessExport();
accessExport1.DatabaseName = "test.mdb";
accessExport1.DataFormats.CultureName = "zh-CN";
accessExport1.DataFormats.Currency = "c";
accessExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
accessExport1.DataFormats.Float = "g";
accessExport1.DataFormats.Integer = "g";
accessExport1.DataFormats.Time = "H:mm";
accessExport1.SQLCommand = oleDbCommand1;
accessExport1.TableName = "ExportData";
oleDbConnection1.Open();
accessExport1.SaveToFile();
}
Private Sub btnMSAccess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMSAccess.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 accessExport1 As New Spire.DataExport.Access.AccessExport()
accessExport1.DatabaseName = "test.mdb"
accessExport1.DataFormats.CultureName = "zh-CN"
accessExport1.DataFormats.Currency = "c"
accessExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
accessExport1.DataFormats.Float = "g"
accessExport1.DataFormats.[Integer] = "g"
accessExport1.DataFormats.Time = "H:mm"
accessExport1.SQLCommand = oleDbCommand1
accessExport1.TableName = "ExportData"
oleDbConnection1.Open()
accessExport1.SaveToFile()
End Sub