Shankar M

Shankar M

  • NA
  • 55
  • 2.7k

Export data issue

Mar 1 2018 6:07 AM
SqlConnection con = new SqlConnection("database connection string");
SqlCommand cmd = new SqlCommand("Select name,address from employee", con);
try
{
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
DataSet ds = new DataSet("New_DataSet");
ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
da.Fill(dt);
ds.Tables.Add(dt);
ExcelLibrary.DataSetHelper.CreateWorkbook("D:\\Employee.xls", ds);
MessageBox.Show("Exported");
}
catch (Exception ec)
{
MessageBox.Show(ec.Message);
}
 
 
using above query when I am exporting data to excel sheet it copies the same date three times in output 

Answers (23)