Help needed in solving a problem, thanks. Code Attached..

Hello All
I am facing a problem working with Berkely DB 4.5.20. I am trying to search in the database whether the key is already present or not. It is working fine with Microsoft Visual Studio but when i use the same code with Code::Blocks editor and MinGW compiler. It is not workig fine.
The code for searching the key is*****
bool CDbProject::IsKeyIndexAvailable(ProjectKey ProKey, UINT DataIndex)
int ret=0;
Dbc *cursorp;
bool flag=false;
cursor(NULL, &cursorp, 0);
//set the key
Dbt key(&ProKey, sizeof(ProKey));
Dbt data;
//search the database for the key.
ret = cursorp->get(&key, &data, DB_SET);
//ret = cursorp->get(&key, &data, DB_NEXT); //Rohit
if (!ret)
{ //if found check if the index is same
do
ProjectDataDetail *myProjDetails;
myProjDetails = (ProjectDataDetail*)data.get_data();
if (myProjDetails->uIndex==DataIndex)
flag = true;
break;
} while (cursorp->get(&key, &data, DB_NEXT_DUP) == 0); //Loop all the duplicate
if (cursorp != NULL)
cursorp->close();
return flag;
And the function to save the data in the database is *******
int CDbHandler::Put(void* pKey, size_t nKeyLen, void* pData, size_t nDataLen)
     int ret = 0;
     Dbt key(pKey, nKeyLen);
     Dbt data(pData, nDataLen);
ret = put(NULL, &key, &data, DB_NODUPDATA);
if (ret==-30996)
ret = ERR_PROJECT_KEY_DATA_ALREADY_EXISTS;
return ret;
Please help...
Thanks in advance,,,
Message was edited by:
user610238

Thanks for the reply Sandra
I try to tell what is happening in the search key function, If still not possible, then i will try to create a stand alone application...
bool CDbProject::IsKeyIndexAvailable(ProjectKey ProKey, UINT DataIndex)
int ret=0;
Dbc *cursorp;
bool flag=false;
cursor(NULL, &cursorp, 0);
//set the key
Dbt key(&ProKey, sizeof(ProKey));
Dbt data;
//search the database for the key.
// SANDRA......If i use DB_SET,as you can see below. It is not able to find the key at all. BUt if i use DB_NEXT, then it is able to find the first key only everytime with the data also (Even if i am looking for some other key, it will find the first key saved always..)
ret = cursorp->get(&key, &data, DB_SET);
//ret = cursorp->get(&key, &data, DB_NEXT); //Rohit
if (!ret)
{ //if found check if the index is same
do
ProjectDataDetail *myProjDetails;
myProjDetails = (ProjectDataDetail*)data.get_data();
if (myProjDetails->uIndex==DataIndex)
flag = true;
break;
} while (cursorp->get(&key, &data, DB_NEXT_DUP) == 0); //Loop all the duplicate
if (cursorp != NULL)
cursorp->close();
return flag;
}

Similar Messages

Maybe you are looking for

  • Jlaunch process is not running aftre system  copy

    Dear All, I am having EP Production server, which is on SGeSAP Cluster. We are planning to remove the cluster and move the EP Production to a standalone server. So we planned to do a system copy po this server. I have done a system copy of EP Product

  • IBooks won't open the first time

    IiBooks will not open the first time  white screen only. It takes 3-4 tries to actually open it

  • Location of security xml files for groups

    We are having some issues migrating security(only) from one sysmte to another in EPM 11.1.2 for a planning application. Is there any other way to migrate security? Where are the xmls for each group's security stored?

  • How to avoid dropping iphone.

    I am delighted with my new purchase but unlike the N95 it does not have a wrist strap. Are there any products out there that facilitate securing a strap with an adhesive. As an oldie I am terrified of dropping the iphone

  • Picture to String Conversion

    Hi All, I am currently struggling trying to convert text that is in the picture format back to its string form. I have used "Draw Text at Point"  Function (Graphics & Sounds - Picture Functions)  to draw multi line text into a picture. I was able to