Esempio n. 1
0
        /// <summary>
        /// 返回一个DataTable
        /// </summary>
        /// <param name="commandText">SQL语句字符串</param>
        /// <param name="timeOut">超时限制</param>
        /// <returns></returns>
        public override DataTable GetDataTable(string commandText, int timeOut)
        {
            IBM.Data.Informix.IfxCommand cmd = new IBM.Data.Informix.IfxCommand(commandText);
            cmd.Connection = (IBM.Data.Informix.IfxConnection) this.connection;
            if (timeOut > 30)
            {
                cmd.CommandTimeout = timeOut;
            }
            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter((IBM.Data.Informix.IfxCommand)cmd);
            try
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                return(dt);
            }
            catch (Exception err)
            {
                throw new EntityException(err.Message);
            }
            finally
            {
                cmd.Dispose();
                cmd = null;
                adapter.Dispose();
                adapter = null;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 返回一个DataTable
        /// </summary>
        /// <param name="cmd">IDbCommand对象</param>
        /// <returns></returns>
        public override DataTable GetDataTable(IDbCommand cmd)
        {
            cmd.Connection = this.connection;
            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter((IBM.Data.Informix.IfxCommand)cmd);

            try
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                return(dt);
            }
            catch (Exception err)
            {
                throw new EntityException(err.Message);
            }
            finally
            {
                adapter.Dispose();
                adapter = null;
            }
        }
Esempio n. 3
0
 /// <summary>
 ///  返回一个IDataAdpter
 /// </summary>
 /// <param name="cmd">IDbCommand对象</param>
 /// <returns></returns>
 public override DbDataAdapter GetAdapter(IDbCommand cmd)
 {
     IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter();
     adapter.SelectCommand = (IBM.Data.Informix.IfxCommand)cmd;
     cmd.Connection        = connection;
     if (isInTransaction)
     {
         cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
     }
     return(adapter);
 }
Esempio n. 4
0
        public override DataRow GetDataRow(string procedurName, ParameterEx[] parameters, int timeOut)
        {
            IDbCommand cmd = this.GetCommand();

            cmd.CommandType    = CommandType.StoredProcedure;
            cmd.CommandText    = procedurName;
            cmd.CommandTimeout = timeOut;
            cmd.Connection     = this.connection;                               //添加连接
            if (parameters != null && parameters.Length > 0)
            {
                this.SetParameters(cmd, parameters);
            }

            DataRow r;

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter();
            adapter.SelectCommand = (IBM.Data.Informix.IfxCommand)cmd;
            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }
            try
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    r = dt.Rows[0];
                }
                else
                {
                    r = null;
                }
                if (parameters != null && parameters.Length > 0)
                {
                    this.ReturnParameters(cmd, parameters);
                }
                return(r);
            }
            catch (Exception err)
            {
                throw new EntityException(err.Message);
            }
            finally
            {
                cmd.Dispose();
                cmd = null;
                adapter.Dispose();
                adapter = null;
            }
        }
Esempio n. 5
0
        public static DataTable ExecuteQuery(IfxCommand command, IfxConnection conn, IfxTransaction trans)
        {
            DataTable result = new DataTable();

            command.Connection  = conn;
            command.Transaction = trans;
            IBM.Data.Informix.IfxDataAdapter datoIFX = default(IBM.Data.Informix.IfxDataAdapter);
            datoIFX = new IfxDataAdapter();
            datoIFX.SelectCommand = command;
            datoIFX.Fill(result);
            datoIFX.Dispose();
            return(result);
        }
Esempio n. 6
0
 /// <summary>
 ///  返回一个IDataAdpter
 /// </summary>
 /// <param name="commandText">SQL语句字符串</param>
 /// <param name="timeOut">超时限制</param>
 /// <returns></returns>
 public override DbDataAdapter GetAdapter(string commandText, int timeOut)
 {
     IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter();
     IBM.Data.Informix.IfxCommand     cmd     = new IBM.Data.Informix.IfxCommand(commandText);
     adapter.SelectCommand = (IBM.Data.Informix.IfxCommand)cmd;
     cmd.Connection        = (IBM.Data.Informix.IfxConnection)connection;
     if (timeOut > 30)
     {
         cmd.CommandTimeout = timeOut;
     }
     if (isInTransaction)
     {
         cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
     }
     return(adapter);
 }
Esempio n. 7
0
        //EJECUTA UN QUERY
        public static DataTable ExecuteQuery(IfxCommand command, string chain)
        {
            DataTable     result      = new DataTable();
            IfxConnection conexionIFX = new IfxConnection();

            IBM.Data.Informix.IfxDataAdapter datoIFX = default(IBM.Data.Informix.IfxDataAdapter);
            conexionIFX = new IfxConnection(chain);
            conexionIFX.Open();
            command.Connection    = conexionIFX;
            datoIFX               = new IfxDataAdapter();
            datoIFX.SelectCommand = command;
            datoIFX.Fill(result);
            datoIFX.Dispose();
            conexionIFX.Close();
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// 返回一个DataRow
        /// </summary>
        /// <param name="commandText">SQL语句字符串</param>
        /// <param name="timeOut">超时限制</param>
        /// <returns></returns>
        public override DataRow GetDataRow(string commandText, int timeOut)
        {
            IBM.Data.Informix.IfxCommand cmd = new IBM.Data.Informix.IfxCommand(commandText);
            cmd.Connection = (IBM.Data.Informix.IfxConnection) this.connection;                                         //添加连接
            if (timeOut > 30)
            {
                cmd.CommandTimeout = timeOut;
            }
            DataRow r;

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter();
            adapter.SelectCommand = (IBM.Data.Informix.IfxCommand)cmd;
            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }
            try
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    r = dt.Rows[0];
                }
                else
                {
                    r = null;
                }
                return(r);
            }
            catch (Exception err)
            {
                throw new EntityException(err.Message);
            }
            finally
            {
                cmd.Dispose();
                cmd = null;
                adapter.Dispose();
                adapter = null;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 返回一个DataTable
        /// </summary>
        /// <param name="procedureName">存储过程名称</param>
        /// <param name="parameters">参数名称</param>
        /// <param name="timeOut">超时时间</param>
        /// <returns></returns>
        public override DataTable GetDataTable(string procedureName, ParameterEx[] parameters, int timeOut)
        {
            IDbCommand cmd = this.GetCommand();

            cmd.Connection     = this.connection;
            cmd.CommandType    = CommandType.StoredProcedure;
            cmd.CommandText    = procedureName;
            cmd.CommandTimeout = timeOut;

            if (parameters != null && parameters.Length > 0)
            {
                SetParameters(cmd, parameters);
            }

            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter((IBM.Data.Informix.IfxCommand)cmd);

            DataTable dt = new DataTable();

            try
            {
                adapter.Fill(dt);
                return(dt);
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
            finally
            {
                cmd.Dispose();
                adapter.Dispose();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 返回一个DataRow
        /// </summary>
        /// <param name="cmd">IDbCommand对象</param>
        /// <returns></returns>
        public override DataRow GetDataRow(IDbCommand cmd)
        {
            cmd.Connection = this.connection;                                   //添加连接
            DataRow r;

            IBM.Data.Informix.IfxDataAdapter adapter = new IBM.Data.Informix.IfxDataAdapter();
            adapter.SelectCommand = (IBM.Data.Informix.IfxCommand)cmd;
            if (isInTransaction)
            {
                cmd.Transaction = (IBM.Data.Informix.IfxTransaction)transaction;
            }
            try
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    r = dt.Rows[0];
                }
                else
                {
                    r = null;
                }
                return(r);
            }
            catch (Exception err)
            {
                throw new EntityException(err.Message);
            }
            finally
            {
                adapter.Dispose();
                adapter = null;
            }
        }