OK, so I'm finally transitioning from VB6 to VS 2005 and it is excruciating. I do a lot of db programming in VB6 and Access 2003 and just trying to connect to a table in VS2005 has taken me several hours. I finally could read data from a table and populate a listbox and then it suddenly stopped working and I get a very cryptic error message.
"Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
This is a work-group database, so I have a system database file I must access in the connection string. It was working and then for some reason the data connection dropped all of the username, password, and system db information. It was still in the connection string, but no longer in the data source properties window.
I tried several things and finally deleted the the data connection and recreated it. I click on "Test Connection" and the connection succeeds. I can see the tables and even use the Query Builder and see the data. When I try to access with code and populate a listbox it fails with the error message above. Its very frustrating.
It is on the "da.Fill(ds, "tblCondition")" line that it bombs. It was working!!!
' Creating connection and command sting
Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='X:\NetProjects\PecsysInload\PecsysAll.mdb';Persist Security Info=True;Password=paswrd;User ID=usrnme;Jet OLEDB:System database='X:\NetProjects\PecsysInload\fmc2003.mdw';Jet OLEDB:Database Password=M2ctsdmrt"
Dim sqlStr As String = "SELECT * FROM tblCondition"
' Create connection object
Dim conn As OleDbConnection = New OleDbConnection(conStr)
' Create data adapter object
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlStr, conn)
' Create a dataset object and fill with data using data adapter's Fill method
Dim ds As DataSet = New DataSet
' Attach dataset's DefaultView to the datagrid control
Dim dv As DataView = ds.Tables("tblCondition").DefaultView
lstCondtions.DataSource = dv
lstCondtions.DisplayMember = "ItemName"
Any help is appreciated. Also, any good books that would ease the transition would be helpful.