Esempio n. 1
0
    public DataTable RunQueryDataTable(string query, IDataParameter[] parameters)
    {
        string key = MSSQLCacheHelper.Key(query, parameters);

        if (!MSSQLCacheHelper.Exists(key))
        {
            DataSet   ds = new DataSet();
            DataTable dt = ds.Tables.Add();

            using (SqlDataAdapter da = new SqlDataAdapter(query, Connection))
            {
                da.SelectCommand.CommandType = CommandType.Text;

                if (parameters != null)
                {
                    foreach (SqlParameter parameter in parameters)
                    {
                        if (parameter != null)
                        {
                            da.SelectCommand.Parameters.Add(parameter);
                        }
                    }
                }

                da.Fill(dt);
                MSSQLCacheHelper.Add <DataTable>(dt, key);
            }
            return(dt);
        }
        else
        {
            return(MSSQLCacheHelper.Get <DataTable>(key));
        }
    }
Esempio n. 2
0
    protected DataTable RunProcedureDataTable(string storedProcName, IDataParameter[] parameters)
    {
        string key = MSSQLCacheHelper.Key(storedProcName, parameters);

        if (!MSSQLCacheHelper.Exists(key))
        {
            DataSet        ds = new DataSet();
            DataTable      dt = ds.Tables.Add();
            SqlDataAdapter da = new SqlDataAdapter(storedProcName, Connection);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;

            foreach (SqlParameter parameter in parameters)
            {
                if (parameter != null)
                {
                    da.SelectCommand.Parameters.Add(parameter);
                }
            }

            da.Fill(dt);

            MSSQLCacheHelper.Add <DataTable>(dt, key);

            return(dt);
        }
        else
        {
            return(MSSQLCacheHelper.Get <DataTable>(key));
        }
    }
Esempio n. 3
0
    protected DataTable RunProcedureDataTable(string storedProcName)
    {
        string key = MSSQLCacheHelper.Key(storedProcName);

        if (!MSSQLCacheHelper.Exists(key))
        {
            DataSet        ds = new DataSet();
            DataTable      dt = ds.Tables.Add();
            SqlDataAdapter da = new SqlDataAdapter(storedProcName, Connection);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.Fill(dt);

            MSSQLCacheHelper.Add <DataTable>(dt, key);

            return(dt);
        }
        else
        {
            return(MSSQLCacheHelper.Get <DataTable>(key));
        }
    }
Esempio n. 4
0
    public DataSet GetData(string query)
    {
        string key = MSSQLCacheHelper.Key(query);

        if (!MSSQLCacheHelper.Exists(key))
        {
            DataSet ds = new DataSet();

            using (SqlDataAdapter da = new SqlDataAdapter(query, Connection))
            {
                da.SelectCommand.CommandType = CommandType.Text;

                da.Fill(ds);
                MSSQLCacheHelper.Add <DataSet>(ds, key);
            }
            return(ds);
        }
        else
        {
            return(MSSQLCacheHelper.Get <DataSet>(key));
        }
    }