Example #1
0
        /// <summary>
        ///   Executes a SQL statement against a connection object.
        /// </summary>
        /// <returns> The number of rows affected. </returns>
        public override int ExecuteNonQuery()
        {
            BindParameters();

            T_CCI_ERROR err = new T_CCI_ERROR();
            int         ret = CciInterface.cci_execute(handle, (char)CCIExecutionOption.CCI_EXEC_QUERY_ALL, 0, ref err);

            if (ret < 0)
            {
                throw new CUBRIDException(err.err_msg);
            }

            columnInfos = CciInterface.cci_get_result_info(conn, handle);

            if (this.Parameters.Count > 0)
            {
                if (this.GetOutModeParameterCount() == 0 || columnInfos == null)
                {
                    CciInterface.cci_close_req_handle(handle);
                    handle = 0;

                    return(ret);
                }

                if ((CciInterface.cci_cursor(handle, 1, CCICursorPosition.CCI_CURSOR_FIRST, ref err)) < 0)
                {
                    throw new CUBRIDException(err.err_msg);
                }

                if ((CciInterface.cci_fetch(handle, ref err)) < 0)
                {
                    throw new CUBRIDException(err.err_msg);
                }

                for (int i = 1; i <= this.Parameters.Count; i++)
                {
                    if (this.Parameters[i - 1].Direction == ParameterDirection.InputOutput || this.Parameters[i - 1].Direction == ParameterDirection.Output)
                    {
                        object value = new object();
                        CciInterface.cci_get_value(conn, i, Parameters[i - 1].CUBRIDDataType, ref value);
                        Parameters[i - 1].Value = value;
                    }
                }
            }

            CciInterface.cci_close_req_handle(handle);
            handle = 0;

            return(ret);
        }
Example #2
0
        internal CUBRIDDataReader ExecuteInternal()
        {
            T_CCI_ERROR err = new T_CCI_ERROR();
            int         ret = CciInterface.cci_execute(handle, (char)CCIExecutionOption.CCI_EXEC_QUERY_ALL, 0, ref err);

            if (ret < 0)
            {
                throw new CUBRIDException(err.err_msg);
            }

            //T_CCI_COL_INFO res;
            columnInfos = CciInterface.cci_get_result_info(conn, handle);

            dataReader = new CUBRIDDataReader(this, handle, ret, columnInfos, ret);

            return(dataReader);
        }