Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [UserDetail]
- UserID=xxxxxxx
- PassWord=xxxxxxxx
- [Connection]
- contact=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE CLEINT MASTER.xls
- DebitISE=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE 1.xls
- DebitLKP=C:UsersinfinityDesktopaadinathfilesALL EVENT FILE FORMATTRADING MASTER FILEISE CLEINT MASTER.xls
- [FilePath]
- DebitISEClient=C:
- [FileName]
- DebitISEClient=Contact_06-07-2015.txt
- private void button1_Click(object sender, EventArgs e)
- {
- string filepath = txtpayoutfile.Text;
- string message = "";
- string mobileno = "";
- string name = "";
- DataSet dsmaster = new DataSet();
- string filepathc = ini.IniReadValue("Connection", "contact");
- if (filepath == "")
- {
- MessageBox.Show("Import Contact File");
- this.Show();
- }
- if (Path.GetExtension(filepath) == ".xls")
- {
- oledbConn1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepathc + ";Extended Properties="Excel 8.0;HDR=Yes;IMEX=2"");
- }
- else if (Path.GetExtension(filepath) == ".xlsx")
- {
- oledbConn1 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepathc + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
- }
- oledbConn1.Open(); ////exception occurs here
- if (Path.GetExtension(filepath) == ".xls")
- {
- oledbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties="Excel 8.0;HDR=Yes;IMEX=2"");
- }
- else if (Path.GetExtension(filepath) == ".xlsx")
- {
- oledbConn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=1;';");
- }
- OleDbCommand cmdoledb = new OleDbCommand("Select * from [Sheet1$3:3000]", oledbConn);
- OleDbDataAdapter daoledb = new OleDbDataAdapter(cmdoledb);
- DataTable dt = new DataTable();
- daoledb.Fill(dt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement