473,791 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error reading excel using OleDb

Hi
I try to execute an sample how to read and write excel sheets using OleDb
When opens the connection, the objConn.Open gave me this error:
"Request for the permission of type 'System.Data.Ol eDb.OleDbPermis sion,
System.Data, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed."
And appears the following message:
System.Exceptio n {System.Securit y.SecurityExcep tion}
Any idea to solve this error?
I work with VS 2005, using C#
TIA
Abel
Sep 6 '06 #1
4 6415
Are you doing this in ASP.NET perhaps, and trying to access an Excel
sheet on a network share, or on a part of the drive that ASPNET doesn't have
access to?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Abel" <Ab**@discussio ns.microsoft.co mwrote in message
news:89******** *************** ***********@mic rosoft.com...
Hi
I try to execute an sample how to read and write excel sheets using OleDb
When opens the connection, the objConn.Open gave me this error:
"Request for the permission of type 'System.Data.Ol eDb.OleDbPermis sion,
System.Data, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed."
And appears the following message:
System.Exceptio n {System.Securit y.SecurityExcep tion}
Any idea to solve this error?
I work with VS 2005, using C#
TIA
Abel

Sep 6 '06 #2
I'd concur.

Permissions on the file, usually because of an asp.net environment.

Also, you have to be very anal with the connection string with excel. Every
space and ; matters.

"Abel" <Ab**@discussio ns.microsoft.co mwrote in message
news:89******** *************** ***********@mic rosoft.com...
Hi
I try to execute an sample how to read and write excel sheets using OleDb
When opens the connection, the objConn.Open gave me this error:
"Request for the permission of type 'System.Data.Ol eDb.OleDbPermis sion,
System.Data, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed."
And appears the following message:
System.Exceptio n {System.Securit y.SecurityExcep tion}
Any idea to solve this error?
I work with VS 2005, using C#
TIA
Abel

Sep 6 '06 #3
Nicholas
This is my code:
Is a class program, to process in backoffice

public System.Data.Dat aSet GetDataFromExce lFile(String File_name) {
try {
string strConn = "Provider=Micro soft.Jet.OLEDB. 4.0;";
strConn += "Data Source= " + File_name + "; Extended Properties=Exce l
8.0;HDR=Yes;IME X=1";
OleDbConnection ObjConn = new OleDbConnection (strConn);
====here fails => ObjConn.Open();
OleDbCommand ObjCmd = new OleDbCommand("S ELECT * FROM [ExcelFileTest$]",
ObjConn);
OleDbDataAdapte r objDA = new OleDbDataAdapte r();
objDA.SelectCom mand = ObjCmd;
DataSet ObjDataSet = new DataSet();
objDA.Fill(ObjD ataSet);
ObjConn.Close() ;
return ObjDataSet;
} catch(Exception excepcion) {
return null;
}
}

"Nicholas Paldino [.NET/C# MVP]" wrote:
Are you doing this in ASP.NET perhaps, and trying to access an Excel
sheet on a network share, or on a part of the drive that ASPNET doesn't have
access to?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Abel" <Ab**@discussio ns.microsoft.co mwrote in message
news:89******** *************** ***********@mic rosoft.com...
Hi
I try to execute an sample how to read and write excel sheets using OleDb
When opens the connection, the objConn.Open gave me this error:
"Request for the permission of type 'System.Data.Ol eDb.OleDbPermis sion,
System.Data, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed."
And appears the following message:
System.Exceptio n {System.Securit y.SecurityExcep tion}
Any idea to solve this error?
I work with VS 2005, using C#
TIA
Abel


Sep 7 '06 #4
Sloan
See my answer to Nicholas, this isnt an ASP Program, is winforms
Yo can see my code
This is an environment problem
You can see on the stacktrace:

StackTrace " at System.Security .CodeAccessSecu rityEngine.Chec k(Object
demand, StackCrawlMark& stackMark, Boolean isPermSet)\r\n at
System.Security .PermissionSet. Demand()\r\n at
System.Data.Com mon.DbConnectio nOptions.Demand Permission()\r\ n at
System.Data.Ole Db.OleDbConnect ion.PermissionD emand()\r\n at
System.Data.Ole Db.OleDbConnect ionFactory.Perm issionDemand(Db Connection
outerConnection )\r\n at
System.Data.Pro viderBase.DbCon nectionClosed.O penConnection(D bConnection
outerConnection , DbConnectionFac tory connectionFacto ry)\r\n at
System.Data.Ole Db.OleDbConnect ion.Open()\r\n at
ProcessExcelFil e.Form1.GetData FromExcelFile(S tring File_name)"
Understand?
Regards
Abel

"sloan" wrote:
I'd concur.

Permissions on the file, usually because of an asp.net environment.

Also, you have to be very anal with the connection string with excel. Every
space and ; matters.

"Abel" <Ab**@discussio ns.microsoft.co mwrote in message
news:89******** *************** ***********@mic rosoft.com...
Hi
I try to execute an sample how to read and write excel sheets using OleDb
When opens the connection, the objConn.Open gave me this error:
"Request for the permission of type 'System.Data.Ol eDb.OleDbPermis sion,
System.Data, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed."
And appears the following message:
System.Exceptio n {System.Securit y.SecurityExcep tion}
Any idea to solve this error?
I work with VS 2005, using C#
TIA
Abel


Sep 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10699
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It appears to be in the OLEDB driver also. My connection was: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" & "Extended Properties='Text;HDR=NO;FMT=Delimited'"
3
7592
by: hkappleorange | last post by:
I connect to mdb file using the following codes. How should I modify it if I want to connect to Excel instead ? <%@ Import Namespace="System.Data.OleDb" %> <% Dim conAuthors As OleDbConnection Dim cmdSelectAuthors As OleDbCommand Dim dtrAuthors As OleDbDataReader
4
5209
by: Phoebe. | last post by:
Hi, Good Day! Reading 1 excel file into a dataset is fine. How can I read multiple excel with the same data structure into 1 dataset? How can I append those data? Can someone help? Thanks in advanced. rgds,
3
3287
by: RJN | last post by:
Hi I've a template excel file which has all the calculations defined. There are certain input values to be entered which gives a lot of output to the user. I don't want to expose the excel sheet to the user as calculations become visible. I'm writing a web interface which takes the input values from user, updates the excel sheet and returns the recalculated output from the excel file. I'm using ADO.Net to update and read the excel file.
9
22505
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What namespaces and classes should I use and how? -- dba123
1
5195
by: Chris Yan | last post by:
Hi All I have an excel sheet with Chinese characters in them. I'm using the OLEBE 4.0 Jet Driver in C# Microsoft Visual Studio 2005 to read from the Excel sheet and then enter into mySQL database. The problem isn't with mysql but with C# reading the chinese characters from Excel.
1
1046
by: Ahmd | last post by:
Error: - the process cannot access the file. XXXXX.xls becuase it is being used by another process. I used OLE DB for opening EXCEL File ; - ' Connect to the Excel Spreadsheet Dim xConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("~/ ExcelImportPayOut.xls") & ";" & _ "Extended Properties=Excel 8.0;"
1
10419
by: =?Utf-8?B?U2hlZXMgQWJpZGk=?= | last post by:
I read an article on the link: http://support.microsoft.com/default.aspx?scid=kb;en-us;306572 related to reading data from Excel using OLEDB The topic's heading is: How to query and display excel data by using ASP.NET, ADO.NET, and Visual C# .NET I am trying with the same code in Visual Studio 2005 in ASP.NET application. The code i am using is: protected void Page_Load(object sender, EventArgs e) { String connectionString...
9
2258
by: gerryR | last post by:
Hi All I've a simple web app that pulls data from an excel sheet into a small aspx page. When I browse the site through VS2005 everything works fine. When I copy the project to IIS wwwroot folder I get a ERROR Data source name not found and no default driver specified Data source name not found and no default driver specified]
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.