Another newbie's question (please help) -
12-16-2005
, 04:00 AM
Hello,
I have created 4 databases (main db, and 3 secondary db)
3 secondary db is used to search on spesific "column" (book's title,
book's author, and book's ISBN).
I have problem in creating "log", i can't get/see the error on the
spesified file (err.log).
I tried to create the error just to see if it's being written to the
spesified file, i deleted title.db.
i was supposed to see the error on the err.log and then the application
prompt me with a dialog box, but the application just crashed.
what's wrong with this code ?
thanks in advance, and sorry for my poor english.
----------------------------------------------------------------------------------------------------------------------
ret = db_env_create(&dbenv, 0);
if (ret != 0) {
MessageBox(NULL, "Error Creating Environment!", "Error!", MB_OK);
return (ret);
}
ret = dbenv->open(dbenv, 0, DB_INIT_LOCK | DB_INIT_MPOOL | DB_CREATE |
DB_PRIVATE, 0);
if (ret != 0) {
MessageBox(NULL, "Error Opening Environment!", "Error!", MB_OK);
return (ret);
}
ret = db_create(&title_dbp, NULL, 0);
if (ret != 0) {
MessageBox(NULL, "Error Creating Primary Database!", "Error!", MB_OK);
return (ret);
}
error_file_pointer = fopen("err.log", "rw+");
if (error_file_pointer == NULL) {
MessageBox(NULL, "Error Opening Log File!", "Error!", MB_OK);
return (-1);
}
/* Set up error handling for this database */
dbenv->set_errfile(dbenv, error_file_pointer);
dbenv->set_errpfx(dbenv, "error: ");
/* Database open flags */
flags = DB_CREATE; /* If the database does not exist, create it.*/
/* open the database */
ret = title_dbp->open(title_dbp, /* DB structure pointer */
NULL, /* Transaction pointer */
"title.db", /* On-disk file that holds the database. */
NULL, /* Optional logical database name */
DB_BTREE, /* Database access method */
flags, /* Open flags */
0); /* File mode (using defaults) */
if (ret != 0) {
dbenv->err(dbenv, ret, "Error Opening Database!");
MessageBox(NULL, "Error Opening Database!", "Error!", MB_OK);
return (ret);
}
---------------------------------------------------------------------------------------------------------------------- |