Click here to Skip to main content
15,894,284 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
For several years, I have been using a standard OleDbConnection, named OleDbConnection1 from the toolbox along with the following typical code:
VB.NET
Dim conn As New OleDb.OleDbConnection
conn = OleDbConnection1
     If conn.State = ConnectionState.Closed Then
         conn.Open()
     End If


I am now using Visual Studio 2008, With VB.Net installed on an XP machine and using the Framework 3.5. Suddenly this old reliable code no longer allows a connection to an Access table to be opened during program execution. To add insult to injury, the static Connection String test shows a Successful Connection.

I am really open to suggestions as to what has happened.
Posted
Updated 10-Feb-11 17:40pm
v2
Comments
Nish Nishant 10-Feb-11 23:16pm    
Are any exceptions thrown?
satcomengineer 11-Feb-11 7:08am    
Yes, see my comment under Answer 2

If you can not find the control in toolbax then right click on any item of toolbox and select choose items, select OleDbConnection from the dialog and then you will be able to drag the control on your form.

Another option,
you can create a new object of OleDbConnection nad use it

Dim conn as new OleDbConnection("connectionstring")
 
Share this answer
 
Comments
satcomengineer 11-Feb-11 6:33am    
Covered all that ground long ago. Creating the OleDbConnection in code produces the same result.
Praveen Kumar Upadhyay 11-Feb-11 6:36am    
Is your problem solved, and how??
satcomengineer 11-Feb-11 7:04am    
No but I did trap an exception this morning. "The Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine". Unclear why it was not registered when I installed VS2008. I could use some guidance on this registration process.
Hope this[^]may help you.
 
Share this answer
 
Comments
satcomengineer 11-Feb-11 6:32am    
Thanks but I had seen that from 2005. I have been using my connections successfully for years past that.
Praveen Kumar Upadhyay 11-Feb-11 6:34am    
Is your problem solved, and how??
satcomengineer 12-Feb-11 0:04am    
It appears the problem lies in switching from the 32 bit compiler to a 64 bit compiler.

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/33073277-a82c-4ffd-8090-0433ab7e96bf

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900