Solved

Disconnecting Data and DBGrid

Posted on 2001-08-14
7
165 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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