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