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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# DBlink issue 1

Status
Not open for further replies.

WalterHeisenberg

Technical User
Mar 28, 2008
159
Hello,

I have been asked to convert some vb windows apps into c#. I seem to be unable to create a dblink although I have had no problems in anything else I have done.

Here is the code I have so far:
Code:
    public AccpacSession OpenSession(AccpacSession session)
        {
            session.Init("", "XX", "XX1000", "56A");
            session.Open(userName, userPassword, dataBase, sessionDate, flags, reserved);
            return session;
        }

        public AccpacDBLink CreateCompanyLink(AccpacSession session)
        {
            AccpacDBLink link = session.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);            
            return link;
        }
  session = lib.OpenSession();                
  dbLink = lib.CreateCompanyLink(session);
I get the following error:

failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))..

I am using Interop.AccpacCOMAPI.dll in many other projects (all vb) with no issues. The session is indeed being opened. I am using accpac 5.6 PU2, .net 4.0, sql svr 2008 r2, windows 7 with UAC disabled.

Feel like I must be missing something obvious but this is driving me up a wall! Thank you for reading this.
 
I agree with you but in this case I don't have a choice. We have an old export process that generates csv files to import that must be redone to automatically create the invoices in Accpac and must be redone in C#.
 
Do you have multiple versions of Accpac installed on your workstation?
 
And I say you do have a choice. VB still works great, I write new Accpac programs in it every day.

FWIW, a 64-bit compiler won't work.
 
And does the program need to access Accpac data through COM? If you're just exporting data what about a straight database connection?
 
Thanks for the responses guys. Boss says it is c# so c# it is!

I am on a 32 bit machine with 1 version of Accpac installed. I tried changing the platform to x86 but it did not make a difference.
Our old app made the csv to import into Accpac the new app will directly create the batches for them. This is why we need to go through the API.
 
Which actual line gives you the error?

Also - I'd avoid a variable name like 'session'.
 
The line that gives me the error is:

dbLink = lib.CreateCompanyLink(session);

Before I had:
Code:
AccpacDBLink dbLink = new AccpacDBLink();
...
dbLink = lib.CreateCompanyLink(session);
I changed this to:
Code:
AccpacDBLink dbLink = lib.CreateCompanyLink(session);
and now it works! However, I am stuck on how to create a view as in VB I would just use:
Code:
Dim CSCALENDAR As AccpacCOMAPI.AccpacView
 
Searching this forum using "AccpacCOMAPI.AccpacView" found a few .Net code examples. Do any of them help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top