developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks




Open a database in C++ via the replicaid
Luc Pannekoeke 11/19/2008 11:15 AM
Toolkits All Releases All Platforms


I have a problem with the C++ api, trying to open a database via the replicaid. When I do it via the path it works fine.

Microsoft C++ exception: unsigned long at memory location 0x0027f740.." on line with the db.GetFilepath (the returned db handle is invalid)
The replicaID is correct.

Part of the code is included

LNNotesSession Session;
LNDatabase db;
LNString MoonDatabase; // = "applications\\MQInterface\\MQINTERFACE.nsf";
DBID ReplicaId;
if (Session.Init(argc, argv))
{
cout << "\nUnable to initialize the API" << endl;
return(2);
}
MoonDatabase = "C1256F82:00487CF0";
if (GetReplicaId(MoonDatabase, ReplicaId)){
cout << "replica values " << ReplicaId.Innards[0]<< ":" << ReplicaId.Innards[1];
Session.GetDatabase(ReplicaId, &db);
//Session.GetDatabase("lp\\PersonalJournal.nsf", &db);

}
db.Open();
LNString filePath = db.GetFilepath();
cout << "\database..." << filePath << endl;

...


bool GetReplicaId(LNString &text, DBID &dbid)
{
try {
char * pch;
char *next_token = NULL;

pch = strtok_s (text.GetTextPtr(),":", &next_token);
dbid.Innards[0] = strtoul(pch, NULL, 16);
pch = strtok_s (NULL, ":", &next_token);
if (pch != NULL) {
dbid.Innards[1] = strtoul(pch, NULL, 16);
} else {
return false;
}
return true;
} catch (...) {
return false;
}
}

Go back