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 ActiveConnection 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 CreateDatabaseFile(string filename)
{
ADOX.CatalogClass catalog = new ADOX.CatalogClass();
catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;D ata Source="
filename + ";Jet OLEDB:Engine Type=5");
ADODB.Connection connection = catalog.ActiveConnection a
ADODB.Connection;
if (connection != null)
{
connection.Close();
}
catalog.ActiveConnection = 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.CatalogClass cat = new ADOX.CatalogClass();
cat.Create("Provider=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