Solved

Disconnecting Data and DBGrid

Posted on 2001-08-14
7
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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 50 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 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