Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disconnecting Data and DBGrid

Posted on 2001-08-14
7
Medium Priority
?
184 Views
Last Modified: 2010-05-02
I have a data control and a dbgrid that is associated with it. It pulls data from an Access Database and shows selected records in the dbgrid. This is fine. However i allow users to delete the database and create a new one. I am having problems deleting the database. I get Path/File access error when i try to run this command Kill App.Path & "\Apt.mdb" . I know it is becuase the database is connected to the data control but i do not know how to disconnect the database so i can delete it without having to close the whole application. Any ideas?
0
Comment
Question by:Maxim10553
7 Comments
 
LVL 3

Expert Comment

by:Diveblue
ID: 6385870
data1.databasename = ""
0
 
LVL 3

Author Comment

by:Maxim10553
ID: 6385875
tried that already
0
 
LVL 12

Expert Comment

by:roverm
ID: 6385890
This will work:

    Set DataGrid1.DataSource = Nothing
    DataEnvironment1.Connection1.Close
    Kill "C:\Program Files\Microsoft Visual Studio\VB98\Copy of NWIND.MDB"

D'Mzzl!
RoverM
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
Valliappan AN earned 200 total points
ID: 6386949
roverm, the qn. is for DBGrid.

Maxim10553,
Try using the dbgrid/data control on a different form, and once you unload the form, it will be automatically disconnected.

0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6387010
Adding to DiveBlue's comments, you need to do a Refresh after setting DatabaseName to "".

Hi, look at this link (look for databasename):
http://www.mail-archive.com/beginning_vb@p2p.wrox.com/msg01425.html

So, it could be:

Data1.DatabaseName = ""
Data1.Refresh

(But still the controls bound to it, will show data, which will disappear once a connection made to data control, as per the above link).

Hope this helps.
0
 
LVL 12

Expert Comment

by:roverm
ID: 6387101
valli_an:
<LOL> You're right !!!
I guess I had my eyes closed when I (tried to) read the question ;-)

D'Mzzl!
RoverM
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6387168
roverm, :>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question