Quote:
Originally Posted by 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.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.
|
I recently experienced this problem.If your development machine is 32 bit while production machine is 64 bit then following code may just save your day!
if (IntPtr.Size == 8)//if the os is 64 bit
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();
cat.Create("Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=E:\\new folder\\yourfilename.mdb;" +
"Jet OLEDB:Engine Type=5");
cat = null;
}
else
{
if (IntPtr.Size == 4)//if the os is 32 bit
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=E:\\new folder\\yourfilename.mdb;" +
"Jet OLEDB:Engine Type=5");
cat = null;
}