What happe开发者_如何学运维ns if a database reaches the limit of 4GB of the SQL Server Compact Edition? Is there a special exception for this?
Can I safely catch this event or exception and, let's say, create a new database?
I have not experienced this myself, but it looks like a SqlCeException
will be thrown and the NativeError
property of the contained SqlCeError will have an error code of 25104 (SSCE_M_DATABASETOOBIG).
Here's a listing of SqlCeError
Native Codes related to db engine errors -- the one about the db file being too big is about 2/3 of the way down. The listing is for SQL CE 3.5; you didn't specify what version you were using, but I'm guessing that it wouldn't change.
I don't see why you couldn't catch this exception and then create a new database in your catch
section.
try {
//do something
} catch (SqlCeException cexc){
foeach (SqlCeError aError in cexc.Errors) {
if (aError.NativeError == 25104) { //this is the code for the TOO BIG error code
//handle too big error -- maybe create a new database
}
}
}
I hope this helps!
精彩评论