Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. [UserDetail]
  2. UserID=xxxxxxx
  3. PassWord=xxxxxxxx
  4.  
  5. [Connection]
  6. contact=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE CLEINT MASTER.xls
  7. DebitISE=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE 1.xls
  8. DebitLKP=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE CLEINT MASTER.xls
  9.  
  10. [FilePath]
  11. DebitISEClient=C:
  12.  
  13. [FileName]
  14. DebitISEClient=Contact_06-07-2015.txt
  15.  
  16. private void button1_Click(object sender, EventArgs e)
  17. {
  18.  
  19. string filepath = txtpayoutfile.Text;
  20.  
  21. string message = "";
  22. string mobileno = "";
  23. string name = "";
  24. DataSet dsmaster = new DataSet();
  25. string filepathc = ini.IniReadValue("Connection", "contact");
  26. if (filepath == "")
  27. {
  28. MessageBox.Show("Import Contact File");
  29.  
  30. this.Show();
  31. }
  32. if (Path.GetExtension(filepath) == ".xls")
  33. {
  34. oledbConn1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepathc + ";Extended Properties="Excel 8.0;HDR=Yes;IMEX=2"");
  35. }
  36. else if (Path.GetExtension(filepath) == ".xlsx")
  37. {
  38. oledbConn1 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepathc + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
  39. }
  40.  
  41. oledbConn1.Open(); ////exception occurs here
  42.  
  43.  
  44. if (Path.GetExtension(filepath) == ".xls")
  45. {
  46. oledbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties="Excel 8.0;HDR=Yes;IMEX=2"");
  47. }
  48. else if (Path.GetExtension(filepath) == ".xlsx")
  49. {
  50. oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
  51. }
  52.  
  53. OleDbCommand cmdoledb = new OleDbCommand("Select * from [Sheet1$3:3000]", oledbConn);
  54. OleDbDataAdapter daoledb = new OleDbDataAdapter(cmdoledb);
  55. DataTable dt = new DataTable();
  56. daoledb.Fill(dt);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement