C # Call ADOX to create an ACCESS data file and close the connection

Source: Internet
Author: User
After an ACCESS data file is created with ADOX, the *. ldb file appears until the program is closed. How can I disable the *. ldb file? (What are the disadvantages when it comes out? I didn't think about it. I just didn't want it to appear .) Interop. ADOX. dll should be a com component. Unlike. Net, the garbage collection mechanism has not been introduced in that era.

After an ACCESS data file is created with ADOX, the *. ldb file appears until the program is closed. How can I disable the *. ldb file? (What are the disadvantages when it comes out? I didn't think about it. I just didn't want it to appear .) Interop. ADOX. dll should be a com component. Unlike. Net, the garbage collection mechanism has not been introduced in that era.

After an ACCESS data file is created with ADOX, the *. ldb file appears until the program is closed. How can I disable the *. ldb file? (What are the disadvantages when it comes out? I didn't think about it. I just didn't want it to appear .)

Interop. ADOX. dll should be a com component. Unlike. Net, the garbage collection mechanism has not been introduced in that era, and no Dispose ()...... You cannot perform Dispose () on ActiveConnection.

Set ActiveConnection = null; Catalog = null; in this way, it seems that the pointer is set to null, but the real object has not changed.

In C #, ActiveConnection does not have the Close () method ......

After searching for half a day, I first saw the solution on a Japanese website. Maybe the search method is incorrect.
Finally, the method will be located on the two statements (one of them cannot be used separately, and two statements must be used simultaneously ):

System. Runtime. InteropServices. Marshal. FinalReleaseComObject (catalog. ActiveConnection );
System. Runtime. InteropServices. Marshal. FinalReleaseComObject (catalog );

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

usingADOX; // csc ... /r:Interop.ADOX.dll ...

// ... other code ...

publicbool CreateDataFile()

{

ADOX.Catalog catalog =newCatalog();

try

{

catalog.Create(ConnString);

System.Runtime.InteropServices.Marshal.FinalReleaseComObject(catalog.ActiveConnection);

System.Runtime.InteropServices.Marshal.FinalReleaseComObject(catalog);

returntrue;

}

catch(Exception ex)

{

Console.WriteLine(ex.Message);

returnfalse;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.