Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. using ExcelLibrary.CompoundDocumentFormat;
  2. using ExcelLibrary.SpreadSheet;
  3. using ExcelLibrary.BinaryDrawingFormat;
  4. using ExcelLibrary.BinaryFileFormat;
  5.  
  6. string myConnection = "datasource=root;port=root;username=root;password=root";
  7. MySqlConnection myConn = new MySqlConnection(myConnection);
  8. MySqlCommand cmdDataBase = new MySqlCommand("select name,surname,birth,telephone,email,city,adress,recorddate from doguAkdenizApp.team;", myConn);
  9. try
  10. {
  11. MySqlDataAdapter dataAdapter = new MySqlDataAdapter();
  12. dataAdapter.SelectCommand = cmdDataBase;
  13. dbdataset = new DataTable();
  14. dataAdapter.Fill(dbdataset);
  15. BindingSource bSource = new BindingSource();
  16.  
  17. bSource.DataSource = dbdataset;
  18. dgvEkip.DataSource = bSource;
  19. dataAdapter.Update(dbdataset);
  20.  
  21. DataSet dataSet = new DataSet("ekipDataset");
  22. dataSet.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
  23. dataAdapter.Fill(dbdataset);
  24. dataSet.Tables.Add(dbdataset);
  25. ExcelLibrary.DataSetHelper.CreateWorkbook("ekipDataset.xls", dataSet);
  26. }
  27. catch (Exception ex)
  28. {
  29. MessageBox.Show(ex.Message);
  30. }
  31.  
  32. string myConnection = "datasource=root;port=root;username=root;password=root";
  33. MySqlConnection myConn = new MySqlConnection(myConnection);
  34. MySqlCommand cmdDataBase = new MySqlCommand("select name,surname,birth,telephone,email,city,adress,recorddate from doguAkdenizApp.team;", myConn);
  35.  
  36. MySqlDataAdapter dataAdapter = new MySqlDataAdapter();
  37. dataAdapter.SelectCommand = cmdDataBase;
  38. dbdataset = new DataTable();
  39. dataAdapter.Fill(dbdataset);
  40. BindingSource bSource = new BindingSource();
  41.  
  42. bSource.DataSource = dbdataset;
  43. dgvEkip.DataSource = bSource;
  44. dataAdapter.Update(dbdataset);
  45.  
  46. dbdataset.WriteXml("Ekip_Dataset.xls"); //I am not sure why he used "WriteXml" but i tried as this
  47. MessageBox.Show("Dosya basariyla olusturulmustur.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement