Hi,
I've created a web application and through this I want to import Excel data
to database.
Following is the code that I've written,
*************** *************** *************** *************** *******
string fileLocation = txtboxFileName. Text.ToString() ;
string sheetName = "Import";
string connectionStrin g = @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source="+fileLo cation+";Extend ed Properties=Exce l 8.0";
string strSQL = "select * from ["+sheetName +"$]";
OleDbConnection cn = new OleDbConnection (connectionStri ng); // It's failing
here
cn.Open();
OleDbCommand cm = new OleDbCommand(st rSQL,cn);
OleDbDataAdapte r da = new OleDbDataAdapte r(cm);
DataSet excelDS = new DataSet();
da.Fill(excelDS );
............... .......
............... .......
............... .......
*************** *************** *************** *************** *******
I've used OleDBConnection for reading the excel, but it's giving me a
Security Exception.
Here's the exception:
############### ############### ############### ############### ########
Server Error in '/PreSa' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.
Exception Details: System.Security .SecurityExcept ion: Request failed.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[SecurityExcepti on: Request failed.]
Try2.WebUserCon trol2.btnSend_C lick(Object sender, EventArgs e) +0
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +57
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain() +2112
System.Web.UI.P age.ProcessRequ est() +217
System.Web.UI.P age.ProcessRequ est(HttpContext context) +18
System.Web.Call HandlerExecutio nStep.System.We b.HttpApplicati on+IExecutionSt ep.Execute() +179
System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously) +87
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.2300; ASP.NET
Version:1.1.432 2.2300
############### ############### ############### ############### ########
Please help me as it's very urgent.
Thanks a ton.
Regards,
Lotus