473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Closing Access file created with ADOX.CatalogCla ss

VMI
I'm creating an Access file with the following code, but won't let me erase
it after creating it. How can I close the file immediately after creating
it?

ADOX.CatalogCla ss cat = new ADOX.CatalogCla ss();
cat.Create("Pro vider=Microsoft .Jet.OLEDB.4.0; " +
"Data Source=" + sFileName + ";" +
"Jet OLEDB:Engine Type=5");
cat=null; // Does NOT work

Thanks.

Nov 16 '05 #1
3 7664
Hi,

Try this:

Marshal.Release ComObject(cat);
cat = null;
GC.Collect(); // This is the last resort - don't use if ReleaseComObjec t
alone helps.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"VMI" <vo******@yahoo .com> wrote in message
news:Oi******** ********@TK2MSF TNGP09.phx.gbl. ..
I'm creating an Access file with the following code, but won't let me
erase it after creating it. How can I close the file immediately after
creating it?

ADOX.CatalogCla ss cat = new ADOX.CatalogCla ss();
cat.Create("Pro vider=Microsoft .Jet.OLEDB.4.0; " +
"Data Source=" + sFileName + ";" +
"Jet OLEDB:Engine Type=5");
cat=null; // Does NOT work

Thanks.


Nov 16 '05 #2
VMI
It worked. Thanks.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:%2******** *********@tk2ms ftngp13.phx.gbl ...
Hi,

Try this:

Marshal.Release ComObject(cat);
cat = null;
GC.Collect(); // This is the last resort - don't use if ReleaseComObjec t
alone helps.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"VMI" <vo******@yahoo .com> wrote in message
news:Oi******** ********@TK2MSF TNGP09.phx.gbl. ..
I'm creating an Access file with the following code, but won't let me
erase it after creating it. How can I close the file immediately after
creating it?

ADOX.CatalogCla ss cat = new ADOX.CatalogCla ss();
cat.Create("Pro vider=Microsoft .Jet.OLEDB.4.0; " +
"Data Source=" + sFileName + ";" +
"Jet OLEDB:Engine Type=5");
cat=null; // Does NOT work

Thanks.

Nov 16 '05 #3

When you create the database, a connection is created to the databas
automatically. You must close the connection to release the lock on th
file. The connection is in the catalog's ActiveConnectio n property.

Using COM references:
1) Microsoft ActiveX Data Objects 2.8 Library
2) Microsoft ADO Ext. 2.8 for DDL and Security

Sample code:

private void CreateDatabaseF ile(string filename)
{
ADOX.CatalogCla ss catalog = new ADOX.CatalogCla ss();
catalog.Create( "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="
filename + ";Jet OLEDB:Engine Type=5");

ADODB.Connectio n connection = catalog.ActiveC onnection a
ADODB.Connectio n;
if (connection != null)
{
connection.Clos e();
}
catalog.ActiveC onnection = null;
catalog = null;
}
VMI Wrote:
I'm creating an Access file with the following code, but won't let m
erase
it after creating it. How can I close the file immediately afte
creating
it?

ADOX.CatalogCla ss cat = new ADOX.CatalogCla ss();
cat.Create("Pro vider=Microsoft .Jet.OLEDB.4.0; " +
"Data Source=" + sFileName + ";" +
"Jet OLEDB:Engine Type=5");
cat=null; // Does NOT work

Thanks


--
FishDawgPosted from http://www.pcreview.co.uk/ newsgroup acces

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
715
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit anyway).... Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = WatcherChangeTypes.Created Then
1
2384
by: Daniel | last post by:
when writing out a file from .net, when is the file created? after the bytes are all written to the hard drive or before the bytes are written to the hard drive?
0
1212
by: Marc | last post by:
I have a Vb 6.0 project The VB 6.0 project with a just a click of the button...exports the calender rows from OUtlook to a MS Access file ( a DB and a table with the calender rows are created) and from this table a crystal report is created.The Db and table don't exist beforehand...they are created.. Right now for test purposes...I have a test machine set-up with just Outlook 2003 set-up and on that test machine I manually tried to...
10
7441
by: Minh | last post by:
I search in all the Disscussion but can not found. How can I create a MS Access Database file using C# code with a given Table Structure ? For example, I want to create a Access Database File with 2 tables: Student and Department, of course, using C# code, not using MS Access to create manually. In Department table, I will have 3 Columns: DepartmentID (primary key, auto
0
1178
by: swatijogdand | last post by:
Hi..... Again, it's really very urgent. does nebody have the code for connecting a SQL Server table to an access database using ADOX ??? Thanx in adavance, Regards, Swati
4
2915
by: rdemyan | last post by:
I'm using code from the following web page to open the API Browse Folder dialog http://www.mvps.org/access/api/api0002.htm It all works fine. But if the dialog box is open and the user closes Access, the system just hangs and Access apparantly cannot close. I have to open the Windows Task Manager and force the closing (and even that takes quite awhile).
6
1599
by: Steven D'Aprano | last post by:
Closing a file can (I believe) raise an exception. Is that documented anywhere? I've spent a lot of frustrating time trying to track this down, with no luck, which suggests that either my google-foo is weak or that it isn't documented. Is IOError the only exception it can raise? The only thing I have found is this: http://mail.python.org/pipermail/python-bugs-list/2004-November/026031.html Out of curiosity, is there a simple way to...
0
2012
by: rehman | last post by:
Hi, I added reference to COM Component Microsoft ADO Ext. 2.8 for DDL and Security which added a wrapper DLL Interop.ADOX.dll in project references in a web application to create MS Access database dynamically. It all works fine in development environment ( VS 2008 + Win 2003 Server. + 32-bit Machine) The aformentioned web application is deployed on IIS 7 + Win server 2008 + 64 - bit machine, where it throws following exception...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.