Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Securities permission question

Status
Not open for further replies.

ribbons

Technical User
Apr 26, 2007
113
US
I have a .NET program which pulls data from an Access Database. I'm a beginner at .NET and this is a very simple application with a combobox that filters a datagrid. I have used the following code to declare the datasource and to fill the dataadapter:

Code:
 Dim dt As New DataTable()
    
Private Sub frm_manager_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim connStr As String = "Provider =Microsoft.Jet.OLEDB.4.0;" 
"Data Source = I:\SEED_SYS\SD-DATA\seed.mdb"

 Dim sqlStr As String = "SELECT LabNumber.OldLabNumber, LabNumber.SampleType, LabNumber.ReportType, " & _
"LabNumber.LotNumber, LabNumber.Title, LabNumber.CompanyName, LabNumber.DateRec" & _
                                "FROM LabNumber;"


 Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
        dataAdapter.Fill(dt)
        dataAdapter.Dispose()
        dg.DataSource = dt

The problem occurs at the "dataAdapter.Fill(dt)" line. This is the error message I get when I try to run the code:

Code:
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."

Apparently, there is a security setting that has to be set higher. I have been unable to find out how to set this. Any ideas?
 
If you go to I:\SEED_SYS\SD-DATA\ and open the file seed.mdb can you make changes to the file?

-I hate Microsoft!
-Forever and always forward.
 
Yes, I can. And I have written several other applications in VB 6 that use this database with no problem. The problem occurred when I put the dataadapter in code. I can do a simliar thing with the smart tasks in .NET with no problem, but I want more control over the sourcing of the comboboxes, hence the reason I looked up the code itself.

Is there some special permission needed to use OLEDB objects?

ribbons

 
Do you get this same error if you move the mdb to your local machine and access it there? It's possible that application doesn't have enough rights/trust on the network.

Senior Software Developer
 
Yes, I get the same error. Now, here's what's weird. If I do all this with the "whizzy wig" methods, like dragging datagrids off of the datasource tab and such, and not direct coding, I don't have this problem, but I need to have more functionality in the programming than I have been able to figure out with all the Smart Tasks, etc. Is this weird, or what?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top