Accidently converting to 4.0

Hoogie

Member
Joined
Jan 22, 2014
Messages
12
Programming Experience
1-3
I accidently converted my 4.5 .NET framework applciation to 4.0 and then back again without manually editing any code. I now have an error when trying to load up a database using a Oledb connection.

Import and declarations:

VB.NET:
Imports System.Data.OleDb

Public Class frmAutoReport


    Dim conn As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim daReports As New OleDbDataAdapter
    Dim Sql As String

Connectionstring and open:

VB.NET:
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\reports.accdb"

        conn.Open()
        MsgBox("test")

The messsage box does not display and none of my controls have information filled in from the database.

What could cause this? Was something changed automatically when converting that I didn't notice?
 
Presumably the Open call is throwing an exception so catch that and it will tell you what the issue is. Normally the debugger will automatically provide information about unhandled exceptions but, if that code is in the Load event handler for your main form, it's going to get swallowed without notification so you must catch the exception explicitly.
 
Presumably the Open call is throwing an exception so catch that and it will tell you what the issue is. Normally the debugger will automatically provide information about unhandled exceptions but, if that code is in the Load event handler for your main form, it's going to get swallowed without notification so you must catch the exception explicitly.

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Why would switching my VS2012 program's .NET framework affect what is actually registered on my machine? Sorry, how can I register this now?

EDIT: I tried installed the "2007 Office System Driver: Data Connectivity Components" that I have read online that solved some peoples issue with that error, but to no avail. (I also tried the 2010 Redistribute Package, and again, error still occurs). I'm not on a server so reconfiguring the IIS that some people have mentioned doesn't pertain to me. I tried attaching the database source in my program but keeping the current code there and again, same thing. I'm officially running out of ideas aside from starting from scratch... *sigh*. I miss VB6.

SOLUTION: Ugh, I just figured it out. Thought I would share. Apparently converting to .NET framework 4.0 changed my Target CPU ("AnyCPU") setting of "Prefer 32-bit" to unchecked for my program properties. Checking that fixed my issue.
 
Last edited:
This is an example of why you should always post error messages. If I'd seen that error message upfront then I could have told you right away that that was almost certainly the issue. That "Prefer 32-bit" option doesn't exist in .NET 4.0, so when you changed to 4.5 it was set to its default value, which is False.

User error is not a reason to miss VB6. That's like someone driving their car into a tree and sighing about how they miss horse-drawn carriages.
 
Back
Top