Results 1 to 5 of 5

Thread: Application error after closing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    177

    Application error after closing

    Hello

    I have got one VB6 application working on ORACLE database via DAO. In case that application runs longer time and I close it then I got following error:

    The instruction at "0x7c921689" referenced memory at "0xffffffff". The memory could
    not be "read".

    Click on OK to terminate the program.


    This problem doesn't occurr on all computers. It seems that problem can be in connection with database.

    Or where can be this problem. How can I determine failure?

    Thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    177

    Re: Application error after closing

    Hello

    One note:
    Old version of application doesn't handle closing of connection to database.
    Therefore I added this source code into Unload method:

    Code:
    Err.Clear
    On Error GoTo ErrorHandler
        MyDataBase.Close
        Set MyDataBase = Nothing
        MyWorkSpace.Close
        Set MyWorkSpace = Nothing
        Exit Sub
    ErrorHandler:
        MsgBox Err.Description, vbOKOnly + vbCritical
    Old versions without this handling work fine.
    Can it cause this problem?

    I note again that application exits with this error only in case of longer running e.g. half a day and only on some mashines.

    Thanks

  3. #3
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Application error after closing

    OK, don't shoot me for my comments. But why are your connections open for such a long time ¿ Isn't there any way you could perhaps only open the DB once needed, and close it after all your processing is done ¿
    VB.NET MVP 2008 - Present

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    177

    Re: Application error after closing

    This way you preferre is not suitable because most of application's operations work with database and connecting/disconnecting every time takes some time and would slow the application.

    Any ideas?

  5. #5
    Addicted Member Optional's Avatar
    Join Date
    Jan 2010
    Location
    Rudimentary Space
    Posts
    214

    Re: Application error after closing

    Opening a connection and using it to call a stored procedure or execute a piece of SQL and then close it does not take extra time.

    What takes extra time is when your application has to deal with multiple open connections which never get closed. That's one sure way to introduce a memory leak. Memory leaks slow down applications, potentially freeze it and generate all sorts of memory errors.

    For example, you would always have 1 generic method GetConnection and another DestroyConnection (or what ever you want to name them).

    You return a connection object from one and pass it to the other for destruction. you call those generics everytime you want to execute anything against the database.

    You are most likely getting the error due to references in memory to an object (propably a connection object) still having a handle to the application when you are closing it.

    Not opening and closing a connection after you are done using it everytime is very bad practice.

    Off course, this does not mean there never is a reason for having a constant open connection in any application, just your reason is not it.

    Edit
    You could also get the error if you are trying to close the connection during unload after internal VB code has already partially disposed of the object.
    Again, try opening and closing the connection everytime you use it.
    Either that or undo your code changes. It's the only 2 options I can see how to debug this issue.
    Last edited by Optional; Apr 16th, 2010 at 04:33 AM.



    Kind Regards,
    Optional



    If you feel this post has helped in answering your question please return the favour and Rate this post.
    If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.


    VB6 - (DataGrid) Get the Row selected with the right mouse button



Posting Permissions

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



Click Here to Expand Forum to Full Width