TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
MR alaa
NA
631
21.5k
excel connection string
Apr 5 2016 7:59 AM
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
}
Reply
Answers (
3
)
generating Unique code
Internal Server Error 500.21 In IIS