Sign in to follow this  

Fully Closing Access Database

This topic is 2852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a .NET App that uses an Access database (not my first choice of db, but it's a requirement). After performing a few inserts on the db, I need to move the .mdb file. I get errors when I try to do this as it seems that the file is still open. I assume this means that the database connections are not fully closed. (If I stop debugging, I can move the file, so it's definitely the app that has it open.) I wondering if there's a step I'm missing to properly close my connections.
        Dim dbConn As OleDbConnection = New OleDbConnection(connString)

        dbConn.Open()
        Try
            Dim cmd As OleDbCommand = New OleDbCommand()
            cmd.Connection = dbConn
            cmd.CommandText = query
            cmd.Parameters.Add(New OleDbParameter(fieldName, fieldValue))
            cmd.ExecuteNonQuery()
            cmd.Dispose()
        Catch
            dbConn.Close()
            Throw
        End Try

        dbConn.Close()



Share this post


Link to post
Share on other sites

This topic is 2852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this