locked
Connection problem to sage using C# RRS feed

  • Question

  • Hello EveryOne,

     

         I am experiencing some problems to connect to sage using sage data objects in C# .

    I have installed sage 50 Accounts 2011 on my machine. And i am trying to connect to sage using C# application.

    I have given adminstrative permissions to my visual studio. i have registered the following things also using administrative permission.

    regsvr32.exe "C:\Windows\System32\Sg50SDOEngine170.DLL"

    regsvr32 sg50SDOEngine170.dll


    c:\windows\Microsoft.Net\Framework\v2.0.50727 \REGTLIBv12.EXE  SDOENG170.TLB

    Go to Project | Add Reference, choose the COM tab and then select 'Sage Data Objects 17.0'. Choose Select and then OK.


    But still i get the following error

    I get error on    oWS.Connect(szDataPath, "", "", "SDO EXAMPLE");

    The error is as follows:

    Sage Data Objects is not registered. Please contact the supplier of this application.

    But when if i run the same application on another machine with administrative rights it works.

    Can any one help me out with it ??

    Here is my code

     

       //Declare Variables

                SageDataObject170.SDOEngine oSDO = new SageDataObject170.SDOEngine();

                SageDataObject170.WorkSpace oWS;

                String szDataPath;



                //Instantiate WorkSpace

                oWS = (SageDataObject170.WorkSpace)oSDO.Workspaces.Add("Example");



                //Show select company dialog

                szDataPath = oSDO.SelectCompany("C:\\ProgramData\\Sage\\Accounts\\2011\\");
                //szDataPath = "C:\\ProgramData\\Sage\\Accounts\\2011\\";


                //Try a connection, will throw an exception if it fails

                try
                {

                    //Leaving the username and password blank generates a login dialog

                    oWS.Connect(szDataPath, "", "", "SDO EXAMPLE");

                    //MessageBox.Show("Connected!");

                    //Disconnect

                    oWS.Disconnect();

                }

                catch (Exception ex)
                {

                    string strMsg = ex.Message;
                    //MessageBox.Show("SDO Generated the Following Error: \n\n" + ex.Message, "Error!");

                }

     

    Thanks & Regards,


    Kiran Nakhale

    Monday, February 7, 2011 5:48 AM

Answers