Results 1 to 4 of 4

Thread: Accidently converting to 4.0

  1. #1
    Hoogie is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Jan 2014
    Posts
    12
    Reputation
    42

    Accidently converting to 4.0

    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:

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

    Code:
    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?

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    13,814
    Reputation
    1707
    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.

  3. #3
    Hoogie is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.5
    Join Date
    Jan 2014
    Posts
    12
    Reputation
    42
    Quote Originally Posted by jmcilhinney View Post
    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 by Hoogie; 01-22-2014 at 7:48 PM.

  4. #4
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    13,814
    Reputation
    1707
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •