I’m new to AccPac programming but have had smooth sailing up to this point. I’m currently calling the AccPac COMAPI (v5.3.a) from a C++ program. I can access the database and manipulate the data there.
My snag is when I call FetchLock. After calling FetchLock the row is *not* locked until I actually call Update. I have even gone so far as to call FetchLock and then edit the row with another program, invalidating the fetched information. The update and subsequent transaction complete with no errors. I’m hoping there is something I am doing wrong with my calling.
While FetchLock is documented to return a Boolean value I get back a -1 (0xFFFFFFFF). While this is a valid true for a boolean, it is also the error code for VC_WARNING. When I access the error object after getting the Boolean back, there are no errors logged.
I’ve included the calling sequence I am using. All the calls are completing with no errors and no exceptions thrown.
Is this a known bug in the Accpac API, or am I simply using it incorrectly?
Thanks,
Ryan.
Call Sequence: (NOTE: I have removed error checking)
My snag is when I call FetchLock. After calling FetchLock the row is *not* locked until I actually call Update. I have even gone so far as to call FetchLock and then edit the row with another program, invalidating the fetched information. The update and subsequent transaction complete with no errors. I’m hoping there is something I am doing wrong with my calling.
While FetchLock is documented to return a Boolean value I get back a -1 (0xFFFFFFFF). While this is a valid true for a boolean, it is also the error code for VC_WARNING. When I access the error object after getting the Boolean back, there are no errors logged.
I’ve included the calling sequence I am using. All the calls are completing with no errors and no exceptions thrown.
Is this a known bug in the Accpac API, or am I simply using it incorrectly?
Thanks,
Ryan.
Call Sequence: (NOTE: I have removed error checking)
Code:
//Create the instance.
Session.CreateInstance(__uuidof(AccpacCOMAPI::AccpacSession));
//Initialize and open the session.
Session->Init(_T(“”), _T(“XZ”), _T(“XZ1000”), _T(“53A”));
Session->Open(_T(“USER”), _T(“Pass”), _T(“DB Name”), Date, 0, _T(“”));
//Open a DBLink to the company.
DBLink = Session->OpenDBLink(AccpacCOMAPI::DBLINK_COMPANY, AccpacCOMAPI::DBLINK_FLG_READWRITE);
//Open a view and retrieve the fields.
View = DBLink->OpenView2(_T(“MX0001”), NULL);
View->Init();
Fields = View->Fields;
//---------------------Beginning of fetchlock code------------------
DBLink->TransactionBegin(&TransactionLevel);
View->Browse(_T(“SQL Search string”));
View->FetchLock(); //Note: The row is *not* locked at this point.
//Edit Information
View->Update(); //Note: At this point the row is locked.
View->UnLock(); //Note: This does not actually unlock the row.
DBLink->TransactionCommit(&TransactionLevel); //Note: This unlocks the row.
//--------------------End Fetchlock Code-----------------------------
Session->Close();