KE50
KE50

Reputation: 556

Delphi quickbooks

Am trying to connect to a quickbooks company file through the qbfc library using delphi 7.

Imported the type Library which has created a QBFC12Lib_TLB file

Included the file to my form's uses list

Code for connecting to the library

var
  TempSession : QBSessionManager;
  TempRequest : IMsgSetRequest;
  TempCustomer : ICustomerAdd;
  TempResponse : IMsgSetResponse;
  AppID, AppName : WideString;
begin
  AppID := '123';
  AppName := 'Hello';
  TempSession.OpenConnection2(AppID, AppName, ctLocalQBDLaunchUI);
  TempSession.BeginSession('', omDontCare);

But an access violation error occurs on "TempSession.OpenConnection2 ...."

Has anyone tried this or could anyone have some samples on how to do this?

Upvotes: 0

Views: 717

Answers (1)

Sam
Sam

Reputation: 2683

As Ken White suggests (and as shown in this SO question), you need to instantiate the QBSessionManager object before you call OpenConnection2

QBSessionManager TempSession = new QBSessionManager();

or possibly (although I could not find any examples that used this notation)

TempSession := QBSessionManager.Create();

Upvotes: 2

Related Questions