Exemple #1
0
        public DataSet ExecuteSelect(string sql, IEnumerable <DbParameter> parameters)
        {
            DbConnection conn = DbAdapter.CreateConnection(ConnectionString);

            conn.Open();

            DbCommand cmd = conn.CreateCommand();

            cmd.CommandText = sql;

            foreach (DbParameter dbParam in parameters)
            {
                cmd.Parameters.Add(dbParam);
            }

            DataSet       ds      = new DataSet();
            DbDataAdapter adapter = DbAdapter.CreateAdapter();

            adapter.SelectCommand = cmd;
            adapter.Fill(ds);

            conn.Close();

            return(ds);
        }
Exemple #2
0
        public DataSet ExecuteSelect(string sql)
        {
            DbConnection conn = DbAdapter.CreateConnection(ConnectionString);

            conn.Open();

            DbCommand cmd = conn.CreateCommand();

            cmd.CommandText = sql;

            DataSet       ds      = new DataSet();
            DbDataAdapter adapter = DbAdapter.CreateAdapter();

            adapter.SelectCommand = cmd;
            adapter.Fill(ds);

            conn.Close();

            return(ds);
        }