/// <summary>
        /// Closes the <see cref="T:System.Data.IDataReader"/> Object.
        /// </summary>
        public void Close()
        {
            MapiFactory.CloseQueryHandle(_queryHandle);
            MapiFactory.CloseConnectionHandle(_connHandle);

            IsClosed = true;
        }
Exemple #2
0
        /// <summary>
        ///     Executes the <see cref="P:System.Data.IDbCommand.CommandText" /> against the
        ///     <see cref="P:System.Data.IDbCommand.Connection" /> and builds an <see cref="T:System.Data.IDataReader" />.
        /// </summary>
        /// <returns>
        ///     An <see cref="T:System.Data.IDataReader" /> object.
        /// </returns>
        public IDataReader ExecuteReader()
        {
            var connHandle  = _connection.GetConnectionHandle();
            var queryHandle = MapiFactory.GetQueryHandle(connHandle, CommandText);

            return(new MonetDbDataReader(queryHandle, _connection));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        public void Close()
        {
            if (State == ConnectionState.Closed)
            {
                return;
            }

            MapiFactory.CloseConnectionHandle(_connection);

            State = ConnectionState.Closed;
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        public void Open()
        {
            if (State == ConnectionState.Open)
            {
                throw new MonetDbException("Connection already open.");
            }

            _connection = MapiFactory.GetConnectionhandle(_database.ConnectionInfo);

            State = ConnectionState.Open;
        }
Exemple #5
0
        /// <summary>
        ///     Executes an SQL statement against the Connection object of a .NET Framework data provider, and returns the number
        ///     of rows affected.
        /// </summary>
        /// <returns>
        ///     The number of rows affected.
        /// </returns>
        /// <exception cref="T:System.InvalidOperationException">The connection does not exist.-or- The connection is not open. </exception>
        public int ExecuteNonQuery()
        {
            var connHandle  = _connection.GetConnectionHandle();
            var queryHandle = MapiFactory.GetQueryHandle(connHandle, CommandText);

            var rowsAffected = MapiLib.MapiRowsAffected(queryHandle).To <int>();

            MapiFactory.DieQueryError(connHandle, queryHandle);

            MapiFactory.CloseQueryHandle(queryHandle);

            return(rowsAffected);
        }
Exemple #6
0
        /// <summary>
        ///     Executes the query, and returns the first column of the first row in the resultset returned by the query. Extra
        ///     columns or rows are ignored.
        /// </summary>
        /// <returns>
        ///     The first column of the first row in the resultset.
        /// </returns>
        public object ExecuteScalar()
        {
            var connHandle  = _connection.GetConnectionHandle();
            var queryHandle = MapiFactory.GetQueryHandle(connHandle, CommandText);

            object result = null;

            if (MapiLib.MapiFetchRow(queryHandle) > 0)
            {
                MapiFactory.DieQueryError(connHandle, queryHandle);

                result = MapiLib.MapiFetchField(queryHandle, 0);
                MapiFactory.DieQueryError(connHandle, queryHandle);
            }

            MapiFactory.CloseQueryHandle(queryHandle);

            return(result);
        }
 private void DieQueryError()
 {
     MapiFactory.DieQueryError(_connHandle, _queryHandle);
 }