none
jump to end sub when read dim engdb As New DAO.DBEngine line RRS feed

  • Question

  • Hello,

    I using vb 2017. when project run to <dim engdb As New DAO.DBEngine> line, don't continue next line and it jump to end sub of my form_load. I can't solve it. please help me

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim fullPath As String = AppDomain.CurrentDomain.BaseDirectory
    Dim engdb As New DAO.DBEngine   <====================== read this line and jump to end sub
    Dim db As DAO.Databas    
    db = engdb.OpenDatabase(fullPath & "filename.accdb", False, False)

    ...

    .

    end sub

    Friday, January 11, 2019 4:59 PM

Answers

  •  Put all that code in  the Form Shown event instead of the Form Load event.  It should show you an exception message then.  The Form Load event seems to have a bad habit of hiding exceptions that occur inside it.

    If you say it can`t be done then i`ll try it

    Friday, January 11, 2019 6:06 PM
  • I put code in form show event, when arrive that line, appearance error:

    System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {00000100-0000-0010-8000-00AA006D2EA4} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

     Is your application being compiled to target 32bit (x86) or 64bit (x64) ?

     It sounds like the (DAO) dll file is a 32bit version and you are building your app to target 64bit,  or visa-versa,  the dll is a 64bit version and your app targets 32bit.  I'm not familiar with the dll to know if they make a 32bit and 64bit version or not.


    If you say it can`t be done then i`ll try it

    Friday, January 11, 2019 7:21 PM

All replies

  •  Put all that code in  the Form Shown event instead of the Form Load event.  It should show you an exception message then.  The Form Load event seems to have a bad habit of hiding exceptions that occur inside it.

    If you say it can`t be done then i`ll try it

    Friday, January 11, 2019 6:06 PM
  • Hi

    Personally, I think the problem is due to you using a seriously long and meaningless user name for your post.

    Maybe it will get better if you also remove the trailing underscore as you did for the leading underscore.


    Regards Les, Livingston, Scotland


    • Edited by leshay Friday, January 11, 2019 6:11 PM
    Friday, January 11, 2019 6:08 PM
  • thanks, I try it but that problem is still there. when run code, running load form firstly
    Friday, January 11, 2019 6:34 PM
  • thanks, I try it but that problem is still there. when run code, running load form firstly

     Just to be clear,  you are saying that it does the same thing in the Form Shown event,  and that it still did not show you an exception message?  

     ... If that is what you are saying,  then I don't really have an idea why this is happening.  Perhaps there are some 'Exception Settings' in your project that have been turned off somehow or something?  I never had a problem like this.

    If you say it can`t be done then i`ll try it

    Friday, January 11, 2019 6:51 PM
  • I put code in form show event, when arrive that line, appearance error:

    System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {00000100-0000-0010-8000-00AA006D2EA4} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

    Friday, January 11, 2019 6:53 PM
  • I put code in form show event, when arrive that line, appearance error:

    System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {00000100-0000-0010-8000-00AA006D2EA4} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

     Is your application being compiled to target 32bit (x86) or 64bit (x64) ?

     It sounds like the (DAO) dll file is a 32bit version and you are building your app to target 64bit,  or visa-versa,  the dll is a 64bit version and your app targets 32bit.  I'm not familiar with the dll to know if they make a 32bit and 64bit version or not.


    If you say it can`t be done then i`ll try it

    Friday, January 11, 2019 7:21 PM
  • thanks, its work. I change to 32bit but my system type is 64 bit, anyway its solved.
    Friday, January 11, 2019 7:31 PM
  • now, to open database:

    db = engdb.OpenDatabase(fullPath & "filename.accdb", False, False,"MS Access;PWD=my password")

    appearance this error:

    System.Runtime.InteropServices.COMException: 'Unrecognized database format '<file name>'.'


    Friday, January 11, 2019 7:53 PM
  • now, to open database:

    db = engdb.OpenDatabase(fullPath & "filename.accdb", False, False,"MS Access;PWD=my password")

    appearance this error:

    System.Runtime.InteropServices.COMException: 'Unrecognized database format '<file name>'.'


     You should start a new question for the new problem if you can not find an answer to it.  8)

     First,  I would do a quick google search for the exception message and read through some of the links and see if you find a quick answer.  There seems to be a few different suggestions and answers that may fix your problem in the search results link below.

    Google Search Results


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Friday, January 11, 2019 8:52 PM
    Friday, January 11, 2019 8:50 PM