hi every body
I try to check excel file on my check i make connection string
why it cant read ConnectionString varible and gets me error ??
this my code
string excelexc = DropDown.SelectedValue;
string fileexc = Path.GetExtension(excelexc);
string ConnectionString;
string path;
switch (fileexc)
{
case ".xls":
path = Server.MapPath("~/Schoolresult/" + DropDown.SelectedValue);
ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
break;
case ".xlsx":
path = Server.MapPath("~/Schoolresult/" + DropDown.SelectedValue);
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=\"Excel 12.0;ReadOnly=False;HDR=Yes;\"";
break;
}
OleDbConnection connExcel = new OleDbConnection(ConnectionString);
OleDbCommand cmdExcel = new OleDbCommand();
try
{
//my code goes here on connection string kind
}

Vignesh ManiRank #98 · 22.1K reputationPosted Apr 5, 2016, 4:39 AM EDT
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("../ExcelData.xls") + ";" + "Extended Properties=Excel 8.0;";MR alaaRank #2,683 · 519 reputationPosted Apr 5, 2016, 8:19 AM EDT
Francis SusaimichaelRank #466 · 5.4K reputationPosted Apr 5, 2016, 5:29 PM EDT