blue875@carolina.rr.com wrote:[color=blue]
> 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?[/color]
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