public static DataTable PerformQueryToCompany(bool AllCompany, string selectStatement, List <SqlParameter> SqlParameters, string dataAreaID) { DataTable TotalResults = null; if (AllCompany) //All Company { var CompanyList = GetAllCompanies(); foreach (var Company in CompanyList) { var ext = new DataBaseAccess(); var paramsToSend = new List <SqlParameter>(); foreach (var par in SqlParameters) { paramsToSend.Add(new SqlParameter(par.ParameterName, par.Value)); } paramsToSend.Add(new SqlParameter("AxCompany", Company)); var results = ext.OpenConnectionGetResults(DataBaseAccess.GetDataBaseName(Company), selectStatement, paramsToSend.ToArray()); if (TotalResults != null && TotalResults.Rows.Count > 0) { foreach (DataRow row in results.Rows) { TotalResults.ImportRow(row); } } else { TotalResults = results; } } } else //Just my company { var ext = new DataBaseAccess(); SqlParameters.Add(new SqlParameter("AxCompany", dataAreaID)); var results = ext.OpenConnectionGetResults(DataBaseAccess.GetDataBaseName(dataAreaID), selectStatement, SqlParameters.ToArray()); TotalResults = results; } return(TotalResults); }
public static DataTable openConnectionGetResultsP(string connect, string select, params DbParameter[] parameters) { DataBaseAccess external = new DataBaseAccess(); return(external.OpenConnectionGetResults(connect, select, parameters)); }