Results 1 to 5 of 5

Thread: Database Un-binding?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Sunny SouthWest Florida
    Posts
    5

    Post

    In a large app the main database gets deleted and then replaced with another. For this to happen the app needs to disconnect from the DB. With a DataControl this is easy with .DatabaseName = "". But I have a DBGrid attached to the DataControl and now no matter what I try the DB always reports that it is in use, and therefore can not be deleted. Is there a Property of the DBGRid that will release the DB??? Or is there another approach? Who said VB was simple?

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    can't you just set the DataMode to 1? 0 = bound, 1 = unbound. I don't use databound controls, I prefer to handle it myself so I don't know if it would work.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Sunny SouthWest Florida
    Posts
    5

    Post

    No... DataMode is Design time only (rats).

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    ok, can you clear the database it's bound to? I'm not familiar with the control. I'm at work right now but if no one has come up with an answer by the time I go home, I'll try it and see what I can find out.

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Clearing the Database Name isn't enough, you need to actually Close the Database, try this:
    Code:
    Private Sub cmdRemove_Click()
        'Disconnect from the DB and Delete It
        Data1.Recordset.Close
        Data1.Database.Close
        DBGrid1.ReBind
        Kill$ "C:\Files\db.mdb"
    End Sub
    
    Private Sub cmdConnect_Click()
        'Create a New Copy of the DB and ReConnect to it.
        FileCopy "C:\Files\db1.mdb", "C:\Files\db.mdb"
        Data1.DatabaseName = "C:\Files\db.mdb"
        Data1.Refresh
        DBGrid1.ReBind
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


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