This sample demonstrates how to export data table to sql script.
private void btnSQLScript_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.SQL.SQLExport sqlExport1
= new Spire.DataExport.SQL.SQLExport();
sqlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
sqlExport1.CommitStatement = "COMMIT;";
sqlExport1.DataFormats.CultureName = "zh-CN";
sqlExport1.DataFormats.Currency = "c";
sqlExport1.DataFormats.DateTime = "yyyy-M-d H:mm";
sqlExport1.DataFormats.Float = "g";
sqlExport1.DataFormats.Integer = "g";
sqlExport1.DataFormats.Time = "H:mm";
sqlExport1.FileName = "sample.sql";
sqlExport1.SQLCommand = oleDbCommand1;
sqlExport1.TableName = "TestTable";
oleDbConnection1.Open();
sqlExport1.SaveToFile();
}
Private Sub btnSQLScript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSQLScript.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 sqlExport1 As New Spire.DataExport.SQL.SQLExport()
sqlExport1.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView
sqlExport1.CommitStatement = "COMMIT;"
sqlExport1.DataFormats.CultureName = "zh-CN"
sqlExport1.DataFormats.Currency = "c"
sqlExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
sqlExport1.DataFormats.Float = "g"
sqlExport1.DataFormats.[Integer] = "g"
sqlExport1.DataFormats.Time = "H:mm"
sqlExport1.FileName = "sample.sql"
sqlExport1.SQLCommand = oleDbCommand1
sqlExport1.TableName = "TestTable"
oleDbConnection1.Open()
sqlExport1.SaveToFile()
End Sub