Please help, I have copied some code to connect to a MSAccess database. However when I try to run it I get a Security Exception message.
Weird thing is, in the IDE I can use database explorer to find, open and test the connection to the database.
The database is stored on a shard network drive and unfortunatley I cannot access my C: drive
In wich MSAcces version are you develop??, couse if it's in 2007 your connection it's wrong, if it´s not then you may probably have to add Trusted connection to the connection string =).
In wich MSAcces version are you develop??, couse if it's in 2007 your connection it's wrong, if it´s not then you may probably have to add Trusted connection to the connection string =).
I think he nailed this on the head, your connection string is probably wrong. If you connected to it in the IDE then it offered you to store the connection string where you could reference it as an application setting, but you're manually providing a connection string.
Take a closer look at the connection string generated from the IDE...
Exception System.Security.SecurityException was thrown in debuggee:
Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Unfortunatley I'm stuck with Access97 at the moment, I will try to find out about adding Trusted to the connection. Thanks for the tip.
I tried to find out where the connection string was from the Database browser, that was the reason for checking it out, but I can't seem to find it - any pointers?
Once again thank you, this has been driving me nuts for a couple of weeks.
Argument '2': cannot convert from 'string' to 'System.Data.OleDb.OleDbConnection'
The best overloaded method match for'System.Data.OleDb.OleDbCommand.OleDbCommand(string, System.Data.OleDb.OleDbConnection)' has some invalid arguments
'string' does not contain a definition for'Open'
'string' does not contain a definition for'Close'
connStr.Open() is highlighted,
Have tried changing the string to OleDbConnection, but then I get Cannot implicitly convert type 'string' to 'System.Data.OleDb.OleDbConnection'
Last edited by Hangfire; Mar 10th, 2009 at 12:15 pm.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.