![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
| Hello all, Win2003, VS2005, BerkeleyDb 4.4 recompiled with VS2005 I have some pretty simple code here based on the BerkeleyDb docs: int main() { char *pathtoDb = "c:\\dev\\dbenv\\mydb.db"; char *description = "Grocery bill"; float money = 123.45; Db mydb(NULL, 0); mydb.set_error_stream(&std::cerr); mydb.open(NULL, pathToDb, NULL, DB_BTREE, 0, 0); Dbt key(&money, sizeof(float)); Dbt data(description, strlen(description) + 1); try { int retcode = mydb.put(NULL, &key, &data, DB_NOOVERWRITE); if ( DB_KEYEXIST == retcode ) db.err(retcode, "Duplicate key" ); } catch ( DbException &e ) { std::cout << "Error: " << e.what() << std::endl; } catch ( std::exception &e ) { // output e.what() } mydb.close(0); return (0); } mydb.db started off with no data in it. I run the app once and the call to Db: ut() is 0. I run it twice so that the duplicate key exceptionwill be caught, but an unhandled exception is thrown "Access violation writing location.." Changing the "flags" parameter in Db: ut() from DB_NOOVERWRITE to 0and the application runs fine. So I'm assuming the duplicate key detection specified by DB_NOOVERWRITE is functioning correctly - and that I can't catch the exception correctly. Any help here is appreciated, Ron |
![]() |
| Thread Tools | |
| Display Modes | |
| |