|
-
Jan 14th, 2000, 12:34 PM
#1
Thread Starter
New Member
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?
-
Jan 14th, 2000, 12:38 PM
#2
Hyperactive Member
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.
-
Jan 14th, 2000, 12:43 PM
#3
Thread Starter
New Member
No... DataMode is Design time only (rats).
-
Jan 14th, 2000, 12:46 PM
#4
Hyperactive Member
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.
-
Jan 14th, 2000, 12:54 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|