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 with C# - Compose problem

Status
Not open for further replies.

stdcall

Programmer
Jun 23, 2005
4
CA
Hello all!

I have an experimental piece of code, and it does not work

the code is:
Code:
private void button1_Click(object sender, System.EventArgs e)
        {
            
                         
            try
            {
                string g_czAccPacDBName = "SAMINC";
                string g_czAccPacUID = "DAVE";
                string g_czAccPacPWD = "SSI2003";

                AccpacCOMAPI.AccpacSession Session;

                
                Session = new AccpacCOMAPI.AccpacSession();

                // open the AP session
                //session.Init("", "AS", "AS1000", "52A");
                //
                
                
                Session.Init("", "AS", "AS1000", "52A");
                Session.Open(g_czAccPacUID, g_czAccPacPWD, g_czAccPacDBName, DateTime.Now, 0, "");

                AccpacCOMAPI.AccpacDBLink mDBLinkCmpRW;
                mDBLinkCmpRW = Session.OpenDBLink (AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY,AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);

                AccpacCOMAPI.AccpacDBLink mDBLinkSysRW;
                mDBLinkSysRW = Session.OpenDBLink (AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM,AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);
//GL0008
                //AccpacCOMAPI.AccpacView  GLBATCH1batch;
                //AccpacCOMAPI.AccpacViewFields GLBATCH1batchFields;
                //mDBLinkCmpRW.OpenView ("GL0008", out GLBATCH1batch) ;
                //GLBATCH1batchFields = GLBATCH1batch.Fields ;


                AccpacCOMAPI.AccpacView  GLBATCH1batch;
                AccpacCOMAPI.AccpacView[]  GLBATCH1batchComp = new AccpacCOMAPI.AccpacView[1];
                AccpacCOMAPI.AccpacViewFields GLBATCH1batchFields;
                mDBLinkCmpRW.OpenView ("GL0008", out GLBATCH1batch) ;
                GLBATCH1batchFields = GLBATCH1batch.Fields ;
                GLBATCH1batchComp[0] = GLBATCH1batch;
                object objBatch = (object)GLBATCH1batchComp;
                GLBATCH1batch.Compose(ref objBatch);


//GL0006

                AccpacCOMAPI.AccpacView  GLBATCH1header;
                AccpacCOMAPI.AccpacViewFields GLBATCH1headerFields;
                mDBLinkCmpRW.OpenView ("GL0006", out GLBATCH1header) ;
                GLBATCH1headerFields = GLBATCH1header.Fields ;

//GL0010


                AccpacCOMAPI.AccpacView  GLBATCH1detail;
                AccpacCOMAPI.AccpacViewFields GLBATCH1detailFields;
                mDBLinkCmpRW.OpenView ("GL0010", out GLBATCH1detail) ;
                GLBATCH1detailFields = GLBATCH1detail.Fields ;
                

                Session.Close();
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } 
   

        }

every time I run it, it crashes on this line:
Code:
GLBATCH1batch.Compose(ref objBatch);
the error says that "identifier objbatch is out of scope"

Could anyone please provide a reason for that happening?

Thanks in advance,
Anton.

 
*NOTE: there might be other errors in the code, but as I do not have AccPac on the cumputer I'm currently on, I couldnt write the sample code correctly. Basically, I had a printout with the old stuff I had, and I just added some new things off the top of my head.
But i only need help with the Compose part

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top