Solved

Disconnecting Data and DBGrid

Posted on 2001-08-14
7
172 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 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