strCompanyFile = "D;/Test..QBW";
Item objAcc = new Item("US", 6, 0, strCompanyfile, "Test QB");
Item.sessionManager.OpenConnection(strCompanyfile, "Test QB");
Item.sessionManager.BeginSession(strCompanyfile, ENOpenMode.omDontCare);
then added Item to this company file and then
if (dsItem.Tables[0].Rows[i]["QBCompanyId"] != dsItem.Tables[0].Rows[i + 1]["QBCompanyId"])
{
Item.sessionManager.EndSession();
Item.sessionManager.CloseConnection();
}
This complete code is in loop and should work for next company as from database the next company is D:/ABC.QBW so the strCompanyFile will be "D:/ABC.QBW" and the same code will execute then.
But when I am runnign this code it is showing error that - A QuickBooks company data file is already open and it is different from the one requested or there are multiple company files open.