View Full Version : Compact DB
Em đang sử dụng C# để truy xuất DB Access 2002. Có ai biết cho em hỏi:
1. Làm sao để Compact file DB để nó chạy nhanh hơn?
2. Giả sử file DB bị user xóa, làm cách nào để chúng ta có thể tạo lại một DB trống (việc Add Table thì làm sau)?
Xin cảm ơn nhiều
Mở cái file MDB đó lên bằng Access, sau đó vào Tools->Compact and Repair Database. Xong! :D :D :D
Caí đó thì em biết rồi. Cái em muốn hỏi là code bằng C# ấy. tại vì khi ta giao soft lại chỉ khách hàng làm thế? :D có ai biết chỉ em với
danceswithwolves
14-01-2004, 19:51
A programmatical solution :
1. Add Reference (COM tab) [Microsoft Access Object Library]
2.
Access.ApplicationClass app = new Access.ApplicationClass();
// compact & repair database
app.CompactRepair("originaldb.mdb", "compacteddb.mdb", "dbpassword"); // null 4 blank pwd
// create new database
app.NewCurrentDatabase("newdb.mdb");
chắc thỏa mãn rồi hen.
Sao cái code bác cho em Add Reference rùi nhưng khi chạy nó vẫn báo lỗi không tìm thấy namespace Access gì đấy! bác có thể nói cụ thể hơn không!
Powered by vBulletin® Version 4.2.0 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.