Ejemplo n.º 1
0
        public DataTable ExecuteQuery(string sql, int timeout = -1)
        {
            CheckDispose();

            var provider = CoreFactory.CreateDbProvider(_databaseId);

            using (IDbCommand cmd = provider.CreateTextCommand(sql))
            {
                if (timeout > 0)
                {
                    cmd.CommandTimeout = timeout;
                }
                cmd.Connection = _cnn;
                if (_tx != null)
                {
                    cmd.Transaction = _tx;
                }
                IDbDataAdapter da = provider.CreateAdapter(cmd);

                DataSet ds = new DataSet();
                _affectedRows = da.Fill(ds);

                return(ds.Tables[0]);
            }
        }
Ejemplo n.º 2
0
        public DataTable ExecuteQuery(IDbCommand cmd)
        {
            CheckDispose();

            var provider = CoreFactory.CreateDbProvider(_databaseId);

            cmd.Connection = _cnn;
            if (_tx != null)
            {
                cmd.Transaction = _tx;
            }

            IDbDataAdapter da = provider.CreateAdapter(cmd);
            DataSet        ds = new DataSet();

            _affectedRows = da.Fill(ds);
            return(ds.Tables[0]);
        }
Ejemplo n.º 3
0
        public void ExecuteNonQuery(string sql, int timeout = -1)
        {
            CheckDispose();

            var provider = CoreFactory.CreateDbProvider(_databaseId);

            using (IDbCommand cmd = provider.CreateTextCommand(sql))
            {
                if (timeout > 0)
                {
                    cmd.CommandTimeout = timeout;
                }
                cmd.Connection = _cnn;
                if (_tx != null)
                {
                    cmd.Transaction = _tx;
                }
                _affectedRows = cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 4
0
        public object ExecuteScalar(string sql, int timeout = -1)
        {
            CheckDispose();

            var provider = CoreFactory.CreateDbProvider(_databaseId);

            using (IDbCommand cmd = provider.CreateTextCommand(sql))
            {
                if (timeout > 0)
                {
                    cmd.CommandTimeout = timeout;
                }
                cmd.Connection = _cnn;
                if (_tx != null)
                {
                    cmd.Transaction = _tx;
                }

                return(cmd.ExecuteScalar());
            }
        }