public DataTable GetViewData(string Query, string CmdType) { DbConnection con = null; DataTable DT = null; try { if (Query != "") { con = _dbFactory.GetConnection(); con.Open(); DbCommand cmd = _dbFactory.GetCommand(); cmd.Connection = con; if (CmdType == "SP") { cmd.CommandType = CommandType.StoredProcedure; } cmd.CommandText = Query; DbDataAdapter adapter = _dbFactory.GetAdapter(); adapter.SelectCommand = cmd; DT = new DataTable(); adapter.Fill(DT); } return(DT); } catch (Exception ex) { throw ex; } finally { if (con != null && con.State != ConnectionState.Closed) { con.Close(); } } }