Advertisement

04.28.2008 at 05:42AM PDT, ID: 23358461
[x]
Attachment Details

Trying to connect to access database

Asked by kshumway in Microsoft Visual Basic.Net, .NET

Tags: Visual Basic, VB.NET 2008

I am trying to connect to an already established Access 2003 database.  Initially, I copied the database to a folder on my C:\ drive.  When I test the connection, everything is okay.  However, when I try to access in code, I am getting the following error:

"Request for permission of type 'System.Data.OleDB.OleDbPermission, System.Data, Version = 2.0.0.0, Culture=Neutral,PublicKeyToken=n' failed.  (note - did not type the actual public key token).  

Note, the function "GetDBString" reads the connection string information from an .ini file and returns the string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\BIA\LACNY BCP Planning Tool.mdb'

The code is attached.

Any help would be gratefully appreciated!

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Private Sub frmBIA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ConnectionStr As String
        ConnectionStr = GetDBString()
        connection1 = New OleDb.OleDbConnection(ConnectionStr)
        dsDept = New DataSet("Departments")
        dsDept.Clear()
        cmd = New OleDb.OleDbCommand("SELECT * FROM Departments ORDER BY dept")
        daDept = New OleDb.OleDbDataAdapter
        daDept.SelectCommand = cmd
 
        Try
            connection1.Open()
            daDept.Fill(dsDept, "dept")
            connection1.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
        For Each row As DataRow In dsDept.Tables("dept").Rows
            lstDept.Items.Add(row.Item("Dept"))
        Next
 
    End Sub
[+][-]04.28.2008 at 06:32AM PDT, ID: 21453755

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.28.2008 at 06:55AM PDT, ID: 21453984

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.28.2008 at 07:36AM PDT, ID: 21454378

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.28.2008 at 08:07AM PDT, ID: 21454683

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, .NET
Tags: Visual Basic, VB.NET 2008
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.28.2008 at 09:12AM PDT, ID: 21455291

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628