Add reference COM: C: \ winnt \ system32 \ msjro. dll
Operation:
Tlbimp c: \ winnt \ system32 \ msjro. dll
/Out: e: \ jeky \ netpage \ www.icar365.cn \ bin \ mymsjro. dll
/Namespace: myjro
The Assembly file generated by tlbimp.exe must be placed in the \ bin directory of the ASP. NET application.
After the operation is executed, two files are generated, one is mymsjro. dll, and the other is deleted from the bin directory.
Call:
Using myjro; // namespace
Void compressaccess (){
String strconn1 = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("/bin/IP. mdb ");
String strconn2 = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + server. mappath ("/bin/ip2.mdb ");
Jetengine databaseengin = new jetengine ();
Databaseengin. compactdatabase (strconn1, strconn2 );
}
Well, the core program has been completed, and the next step is simple: ip2.mdb is the compressed database, copy it to IP. mdb, and then delete ip2.mdb.
Note: You must delete ip2.mdb. Otherwise, an error will occur when you perform this operation next time. The error message is displayed: ip2.mdb already exists.