database file locked by aspx

Discussion in 'ASP .Net' started by hkappleorange, Nov 6, 2005.

  1. I ued this code to connect to a mdb file




    A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
    Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )



    However, I found the Access Mdb file is locked and cannot be edited by
    Access even I have closed the connection using



    A.Close()



    The file is simply locked.



    How to avoid this problem and how to fix it ??
     
    hkappleorange, Nov 6, 2005
    #1
    1. Advertising

  2. Do you have the access database open in it's own window while trying to run
    against it?

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "hkappleorange" <> wrote in message
    news:%...
    >I ued this code to connect to a mdb file
    >
    >
    >
    >
    > A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
    > Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )
    >
    >
    >
    > However, I found the Access Mdb file is locked and cannot be edited by
    > Access even I have closed the connection using
    >
    >
    >
    > A.Close()
    >
    >
    >
    > The file is simply locked.
    >
    >
    >
    > How to avoid this problem and how to fix it ??
    >
    >
    >
    >
     
    S. Justin Gengo, Nov 6, 2005
    #2
    1. Advertising

  3. Thanks for replying. I have already closed the Access when I run the aspx
    file. After running this aspx file, I found I cannot open the mdb file using
    Access. I cannot access even I closed all IE windows... help ....

    Is there something I should do in the code to avoid this problem ??

    Many thanks.

    "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> ¼¶¼g©ó¶l¥ó·s»D:...
    > Do you have the access database open in it's own window while trying to
    > run against it?
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    > "hkappleorange" <> wrote in message
    > news:%...
    >>I ued this code to connect to a mdb file
    >>
    >>
    >>
    >>
    >> A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
    >> Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )
    >>
    >>
    >>
    >> However, I found the Access Mdb file is locked and cannot be edited by
    >> Access even I have closed the connection using
    >>
    >>
    >>
    >> A.Close()
    >>
    >>
    >>
    >> The file is simply locked.
    >>
    >>
    >>
    >> How to avoid this problem and how to fix it ??
    >>
    >>
    >>
    >>

    >
    >
     
    hkappleorange, Nov 6, 2005
    #3
  4. Ok,

    And is this happening after you get data out of the database the first time?

    If, for example, you access your data via a datareader you have to close
    the datareader afterward. Also, if an error occurrs while the datareader is
    open you need to make certain to use a try catch finally structure and close
    the reader in the finally section in order to make certain that it closes
    properly each time.

    E.g.

    Try
    '---Open data reader and do some things with the data (while the
    datareader is open the database is locked)
    Catch ex As Exception
    '---Handle any exceptions that may occurr
    Finally
    '---Close the data reader so that the database is no longer locked
    End Try

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "hkappleorange" <> wrote in message
    news:...
    > Thanks for replying. I have already closed the Access when I run the aspx
    > file. After running this aspx file, I found I cannot open the mdb file
    > using Access. I cannot access even I closed all IE windows... help ....
    >
    > Is there something I should do in the code to avoid this problem ??
    >
    > Many thanks.
    >
    > "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com>
    > ¼¶¼g©ó¶l¥ó·s»D:...
    >> Do you have the access database open in it's own window while trying to
    >> run against it?
    >>
    >> --
    >> Sincerely,
    >>
    >> S. Justin Gengo, MCP
    >> Web Developer / Programmer
    >>
    >> www.aboutfortunate.com
    >>
    >> "Out of chaos comes order."
    >> Nietzsche
    >> "hkappleorange" <> wrote in message
    >> news:%...
    >>>I ued this code to connect to a mdb file
    >>>
    >>>
    >>>
    >>>
    >>> A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
    >>> Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )
    >>>
    >>>
    >>>
    >>> However, I found the Access Mdb file is locked and cannot be edited by
    >>> Access even I have closed the connection using
    >>>
    >>>
    >>>
    >>> A.Close()
    >>>
    >>>
    >>>
    >>> The file is simply locked.
    >>>
    >>>
    >>>
    >>> How to avoid this problem and how to fix it ??
    >>>
    >>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    S. Justin Gengo, Nov 8, 2005
    #4
  5. hkappleorange

    Guest

    when using Access, I create a folder, called Data, and put the db in
    there. I then set modify permissions on the whole folder

    access creates a lock file, which goes in this folder. you want modify
    permissions on this file, but it doesn't exist til access is run.

    either way, doing this allows you to have access open while asp.net is
    using it.

    you might have to restart your asp.net worker process to unlock the
    file.

    thx
     
    , Nov 8, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski
    Replies:
    1
    Views:
    2,453
  2. Tommy  B

    pysqlite error: Database locked?

    Tommy B, Jun 7, 2006, in forum: Python
    Replies:
    1
    Views:
    498
    Dennis Lee Bieber
    Jun 7, 2006
  3. Glen Buell
    Replies:
    5
    Views:
    1,051
    Billy Biro
    Feb 6, 2007
  4. Carlos Solis

    web database access locked

    Carlos Solis, Jun 9, 2004, in forum: ASP General
    Replies:
    1
    Views:
    100
    Aaron [SQL Server MVP]
    Jun 9, 2004
  5. TF
    Replies:
    10
    Views:
    269
Loading...

Share This Page