Home All Groups Group Topic Archive Search About

System.Data.OleDb.OleDbPermission issues with Access and VB 2005

Author
25 Oct 2006 12:46 PM
Bill Sempf
I have a reader that is getting a OleDbPermissions error on an Access
database.  I know I have fixed this before, but I completely forget how and I
can't seem to find anything about it except unanswered questions on the
forums and the like. 

The code is based on a strongly typed dataset, built using the baked in VS
2005 tools.  The calling code looks like this:

        Dim copDA As New CopDataSetTableAdapters.copfileTableAdapter
        Dim copDS As New CopDataSet
        copDA.FillBy(copDS.copfile, CInt(siteNumber))
        Dim copRow As CopDataSet.copfileRow = copDS.copfile.Rows(0)
        _siteName = copRow.address

On the FillBy method, this error is generated:

System.Security.SecurityException was unhandled
  Message="Request for the permission of type
'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
  Source="mscorlib"
  StackTrace:
       at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.PermissionSet.Demand()
       at System.Data.Common.DbConnectionOptions.DemandPermission()
       at System.Data.OleDb.OleDbConnection.PermissionDemand()
       at
System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection
outerConnection)
       at
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable,
IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables,
Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior
behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at
StoreCommunication.CopDataSetTableAdapters.copfileTableAdapter.FillBy(copfileDataTable dataTable, Nullable`1 store_num)
       at StoreCommunication.StoreSystems.SetupStore(String siteNumber)
       at StoreCommunication.StoreSystems..ctor(String siteNumber)
       at MicrosHelpdesk.Form1.Label1_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Label.WndProc(Message& m)
       at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
       at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
       at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at MicrosHelpdesk.My.MyApplication.Main(String[] Args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

Thanks in advance.

S

AddThis Social Bookmark Button