473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C# .NET to MS Access OLEDB - Security error

When I run this connection, I get a security error.

String connectStr = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"User Id=USER; Password=PASS;" +
@"Data Source=\\SERVER\DIRECTORY\Data.mdb;" +
@"Jet OLEDB:System
Database=\\SERVER\DIRECTORY\SYSTEM.mdw";

connection = new OleDbConnection(connectStr);
connection.Open(); // <=== error!

the error:
Request for the permission of type 'System.Data.OleDb.OleDbPermission,
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=TOKEN'
failed.

(Keep in mind that anything in all caps here is my own edit, for
security reasons. I assure you, syntax within those areas is correct.)

I've attempted several variations of this connection string, including
Mode = Share Deny None, Persist Security Info = false, and so on. The
database I'm trying to hit is on a server in my network. There is no
password on the database, but my account does have one (included where
PASS is).

I've successfully set up connections within Access forms using these
same connection strings. Why would I have security issues within
VS.NET 2k5?

Feb 20 '06 #1
3 9110
Bri


bl*****@carolina.rr.com wrote:
When I run this connection, I get a security error.

String connectStr = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"User Id=USER; Password=PASS;" +
@"Data Source=\\SERVER\DIRECTORY\Data.mdb;" +
@"Jet OLEDB:System
Database=\\SERVER\DIRECTORY\SYSTEM.mdw";

connection = new OleDbConnection(connectStr);
connection.Open(); // <=== error!

the error:
Request for the permission of type 'System.Data.OleDb.OleDbPermission,
System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=TOKEN'
failed.

(Keep in mind that anything in all caps here is my own edit, for
security reasons. I assure you, syntax within those areas is correct.)

I've attempted several variations of this connection string, including
Mode = Share Deny None, Persist Security Info = false, and so on. The
database I'm trying to hit is on a server in my network. There is no
password on the database, but my account does have one (included where
PASS is).

I've successfully set up connections within Access forms using these
same connection strings. Why would I have security issues within
VS.NET 2k5?


I haven't tried connecting to an MDB via VS.NET or C#. I have done it
via VBScript in an ASP page. The ID and PW are for the Access UserID
that is in the MDW, not the Login ID for Windows (just clarifying). I
did not include the ID and PW in the connection string, but rather
included them on the Connection.Open statement (note that in ASP
Server.MapPath returns the actual path on the server of the relative
path supplied for the file):

strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("\PATH\DATA.mdb") & ";Jet OLEDB:System database=" & _
Server.MapPath("\PATH\DATA.mdw") & ";"
set xConn = Server.CreateObject("ADODB.Connection")
xConn.Open strConn, "UserID", "Password"

Can you try this syntax and see if it works for you? You can find many
good examlpes of connection strings from many languages to many
providers at this site which has helped me a lot:
http://www.carlprothman.net/Default.aspx?tabid=81

--
Bri

Feb 21 '06 #2
C#'s OleDbConnection.Open doesn't take any arguments. It assumes (I
guess) that everything is set up in the ConnectionString property
beforehand. The .Open command is definitely using the connectionString
I send it (I can see it in the Immediate window in VS.NET studio).

I really don't think it's a syntax issue. I've searched several
websites on connection strings, and this seems to follow Access's
syntax. What I'm wondering is what would cause a security issue on an
access database, when the .mdw file is on my computer, no other
programs are using it, and my account is valid? Are there some drivers
I need to configure, or an environment variable perhaps?

Feb 22 '06 #3
Bri

bl*****@carolina.rr.com wrote:
C#'s OleDbConnection.Open doesn't take any arguments. It assumes (I
guess) that everything is set up in the ConnectionString property
beforehand. The .Open command is definitely using the connectionString
I send it (I can see it in the Immediate window in VS.NET studio).

I really don't think it's a syntax issue. I've searched several
websites on connection strings, and this seems to follow Access's
syntax. What I'm wondering is what would cause a security issue on an
access database, when the .mdw file is on my computer, no other
programs are using it, and my account is valid? Are there some drivers
I need to configure, or an environment variable perhaps?


I agree, your syntax should work. Have you tried a test against an
unsecured MDB to make sure that that works? This would eliminate issues
with the Provider and any Windows UserID permissions. If this also fails
then verify that the Windows ID has all rights to the folder(s) that the
MDB and the MDW are in. When Jet opens the MDB and MDW it creates an
associated LDB file (deleted after the last connection closes). If it
can't create, or modify this file then you will get errors.

--
Bri

Feb 22 '06 #4

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

Similar topics

4
by: RM | last post by:
Had VS .Net 2002 installed on W2k Server SP3 and supported a number of web sites. Installed VS .Net 2003 on Friday and now all web sites using .Net & MS ACCESS get this strange error upon open. ...
9
by: Nathan Sokalski | last post by:
I am trying to connect to a Microsoft Access Database from my ASP.NET Application. I use the following code to create my connection string: cmdSelect.Connection = New...
4
by: Oceania | last post by:
Hi All, I did try using the sample code from the ADO.net forum to link one table, it is working fine. But, I got a problem when I tried to link all tables (20 tables)... Please help, thank...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
11
by: CM Manager via DotNetMonster.com | last post by:
I am very frustrated due to this exception error I am receiving. I've tried searching numerous user support groups, Microsoft Support Net, Google, etc. and haven't found exactly my situation....
9
by: dennist685 | last post by:
I created a web project named 'Access' in C:\Inetpub\wwwroot\Access and dropped an .mdb there. I dragged a DetailView to the form, configured it to show two fields of a table, and got...
9
by: Lars Netzel | last post by:
Hi, I have built an application that is driven by an access database. This is then deplaoy onto about 80 clients through an installation package that also proved a local copy of an emtyp...
3
by: Nathan Sokalski | last post by:
When I attempt to access a Microsoft Access database from my website, I recieve the following error: Server Error in '/' Application....
0
by: yukijocelyn | last post by:
I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSource control, and using Gridview to pull the data from the database. I am able...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.