locked
Data connection to database wont close... RRS feed

  • Question

  • User-282213877 posted

    I have an accessdatasource that links to an access database located in my   wwwroot\[whatever] folder...

    I can access the db one time to pull some data to a datagridview, but after that the db remains locked.

    If I close the page, it remains locked and I cannot manually delete the lock file either.

    The only way to get the lock off is to close visual studio 2005 altogether...

     
    Anyone know why this is happening?

    Thanks

    Cavall
     

    Friday, November 17, 2006 5:04 PM

Answers

  • User1132873562 posted

    You have to close your connection manualy

    someOleDbConnection.Close();

    And if you are using a Datareader, you have to close this also

    someDataReader.Close();

    I hope this helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 18, 2006 2:21 AM

All replies

  • User1132873562 posted

    You have to close your connection manualy

    someOleDbConnection.Close();

    And if you are using a Datareader, you have to close this also

    someDataReader.Close();

    I hope this helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 18, 2006 2:21 AM
  • User-2011671055 posted

    Hello there,

    I am having problem with db connection closing behaving strangely. 

    What happens is that sometimes creates dthe ldb file.. but other times it doesn´t

    I controlled over and over again the connection of OleDbConnections and Datareader. Everything is done correctly. 

    If I open the page the connection is left open (ldb file is not deleted), but if I reload that page a few times then ldb file is deleted... 

    am I missing something? is there any other way to make sure all the database connections are closed?

    when the ldb file is not deleted, does that mean that the connection is open?

    cheers

    Thursday, August 18, 2011 10:05 AM
  • User-1199946673 posted

    when the ldb file is not deleted, does that mean that the connection is open?

    It does mean that the connection is not properly closed and/or disposed!

    is there any other way to make sure all the database connections are closed?

    Yes, by using the 'using .... end using' syntax. The oleDb connection object inherits from IDisposable, the connection will always be closed and disposed properly, even if you don't explicilt close the connection...

    Some examples of this syntax (both VB and C#) can be found here:

    http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access

    And is also learns you how to use parameterized queries (in case you didn't use them already...)

    By the way, next time open a new thread instead of reopen an old thread....

    Thursday, August 18, 2011 6:13 PM
  • User-2011671055 posted

    sorry about reopening the thread..

    here´s the new one

    http://forums.asp.net/p/1712207/4560918.aspx/1?p=True&t=634493250403785994

    Friday, August 19, 2011 4:31 AM