using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace ExportData { public partial class ExportData : Form { public ExportData() { InitializeComponent(); PopulateCombo(); } private void PopulateCombo() { cboTables.DisplayMember = "tableName"; cboTables.DataSource = Constructor.GetTables().Tables[0]; } /// /// Click event to export the data /// /// /// private void btnExport_Click(object sender, EventArgs e) { string tableName = String.Empty; string strQuery = String.Empty; DataSet data = new DataSet(); SqlCommand command = new SqlCommand(); try { tableName = cboTables.Text; command = dataTier.TransactionalMethods.BeginSQLTransaction(); strQuery += "SELECT * FROM " + tableName + " "; command.CommandText = strQuery; data = dataTier.ReturnMethods.ReturnDataSet(ref command); utils.validateFolder(utils.ApplicationPath() + "\\export\\"); //export data to xml utils.ExportDataSetToXML(utils.ApplicationPath() + "\\export\\", tableName + ".xml", data); MessageBox.Show("Data Exported successfully."); } catch (Exception ex) { command.Transaction.Rollback(); throw ex; } finally { dataTier.TransactionalMethods.CompleteSQLTransaction(ref command); } } } }