Showing results for 
Search instead for 
Do you mean 

Problem while connecting to sage (hangs up)

New Member
Posts: 1
Country: India

Problem while connecting to sage (hangs up)

I have problems while connecting to sage.


I have made a program in dot net which uses sage in backend.


I have made use of sage 50 accounts 2011


Two to three times the program runs but then after that it hangs up on


this statement     oWS.Connect(szDataPath, "MANAGER", "", "SDO EXAMPLE");


It just shows that the page is loading but doesnot do any thing.


I have added try catch block but it doesnot go in catch block too.


My code is as below



  private List<SageProduct> GetProductFromSage()
            List<SageProduct> lstSagePrdt = new List<SageProduct>();

            # region GetProductsSage

            //Declare Variables

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

            SageDataObject170.WorkSpace oWS = null;

            SageDataObject170.StockRecord oStockRecord;

            String szDataPath;

            //Instantiate WorkSpace

            oWS = (SageDataObject170.WorkSpace)oSDO.Workspaces.Add("StockRecordExamplesss");
            oWS.UI = true;

            //Show select company dialog

            string SageCompany = ConfigurationManager.AppSettings["SageDataPath"];

            //szDataPath = oSDO.SelectCompany(SageCompany);

            szDataPath = SageCompany;

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


                //Leaving the username and password blank generates a login dialog
                    string strError = oSDO.LastError.Text;
                    oWS.Connect(szDataPath, "MANAGER", "", "SDO EXAMPLE");
                    string strErrors = oSDO.LastError.Text;

                catch (Exception ex)
                    string strErrorss = oSDO.LastError.Text;


                oStockRecord = (SageDataObject170.StockRecord)oWS.CreateObject("StockRecord");

                for (int i = 1; i <= oStockRecord.Count; i++)

           prd = new;
                    prd.STOCK_CODE = (string)SDOHelper.Read(oStockRecord, "STOCK_CODE");
                    prd.DESCRIPTION = (string)SDOHelper.Read(oStockRecord, "DESCRIPTION");
                    prd.STOCK_CAT = (Int16)SDOHelper.Read(oStockRecord, "STOCK_CAT");
            catch (System.Exception excptn)

            return lstSagePrdt;


Can please help me out how i can get the problem??



Thanks & Regards,


Kiran Nakhale