Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AccPac COMAPI under C#

Status
Not open for further replies.

stdcall

Programmer
Jun 23, 2005
4
CA
Hello,

I've tried using xAPI and COMAPI in VB6, and I was wondering if its possible to use COMAPI in C#? From reading the forum I can see that it works for people, but somehow i just keep getting compile-time erros.
Could anyone please post a sample code to open a session?

Thanks
 
Hi,
I'm just working on it in C#. Got the initial part of opening a Session, but not able to open a dbLink. The code snippet is shown. The error statement is the last line.


AccpacSessionManager.AccpacSessionMgrClass APSession = new AccpacSessionManager.AccpacSessionMgrClass();
DateTime dt =new DateTime();
dt = System.DateTime.Now;
AccpacCOMAPI.AccpacSession ia = new AccpacCOMAPI.AccpacSessionClass();
ia.Init("", "XX", "AR2100", "513");
ia.Open("ADMIN", "ADMIN", "INTEQC", dt , 0, "");
AccpacCOMAPI.AccpacDBLinkClass dbLink = new AccpacCOMAPI.AccpacDBLinkClass();

//Error Line
ia.OpenDBLink(DBLINK_COMPANY,DBLINK_FLG_READWRITE);

Will be glad if anybody can throw some light on this.

Regards,
Razeen
 
I've been told this works:

public void SignOnCompany2()
{
AccpacCOMAPI.AccpacSession pSession;
AccpacSignonManager.AccpacSignonMgr pSignon;
AccpacCOMAPI.AccpacDBLink pDBLinkCmpRW;
AccpacCOMAPI.AccpacDBLink pDBLinkSysRW;

pSession = new AccpacCOMAPI.AccpacSessionClass();
pSignon = new AccpacSignonManager.AccpacSignonMgrClass();

pSession.Init ("","CS","CS0001", "53A");
pSignon.SignonNewSession (pSession);

if (pSession.IsOpened)
{ pDBLinkCmpRW = pSession.OpenDBLink
(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY,
AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
pDBLinkSysRW = pSession.OpenDBLink
(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM,
AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
}
}

Jay Converse
IT Director
Systemlink, Inc.
 
Ok, thanks alot you guys; I'll try those snippets out next week, once I get to the comp that has AccPac on it, and I'll post any other further questions I might have.

Thanks again.

 
Hi Jayconverse,

Thanks for your code snippet. It really works.

Razeen
 
Hi,
I have the following code in C#.

accpacSession = new AccpacCOMAPI.AccpacSessionClass();
accpacSession.Init ("","AR","AR0031", "53A");
accpacSession.Open("ADMIN", "ADMIN", "INTEQC", dt , 0, "");
if (accpacSession.IsOpened)
{
pDBLinkCmpRW = accpacSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY,AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
pDBLinkSysRW = accpacSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM,AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);

pDBLinkCmpRW.OpenView("AR0031",out invoiceHeader);

The above line throws a COM Exception. Can anybody guess what is wrong here? i basically want to create a new AR batch number through code and then import an invoice batch into this batch number.

Thanks in advance.

Razeen
 
Hi,
Think where the problem is. Ran a database integrity check on Administration Services and got this error.

Administrative Services 5.3A (July 5, 2005 19:48:57) E: Invalid input. Company ID is invalid.

When i open accpac application i get a lot of companies in the dropdown box. Currently i'm using only one company. How can i delete the other companies from the dropdown box?

Am new to using Accpac application.

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top