예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        public MonetDbDataReader(MapiHdl queryHandle, MonetDbConnection connection)
        {
            _queryHandle = queryHandle;
            _connHandle = connection.GetConnectionHandle();

            Init();
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connectionHandle"></param>
 /// <exception cref="MonetDbException"></exception>
 public static void DieConnectionError(MapiConnection connectionHandle)
 {
     if (connectionHandle.Ptr == IntPtr.Zero ||
         MapiLib.MapiError(connectionHandle).Ptr != IntPtr.Zero)
     {
         throw new MonetDbException(MapiLib.MapiErrorString(connectionHandle));
     }
 }
예제 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionHandle"></param>
 /// <exception cref="MonetDbException"></exception>
 public static void DieConnectionError(MapiConnection connectionHandle)
 {
     if (connectionHandle.Ptr == IntPtr.Zero ||
         MapiLib.MapiError(connectionHandle).Ptr != IntPtr.Zero)
     {
         throw new MonetDbException(MapiLib.MapiErrorString(connectionHandle));
     }
 }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        /// <exception cref="MonetDbException"></exception>
        public static MapiHdl GetQueryHandle(MapiConnection connection, string query)
        {
            var queryHandle = MapiLib.MapiQuery(connection, query);

            DieQueryError(connection, queryHandle);

            return(queryHandle);
        }
예제 #5
0
        /// <summary>
        /// Return a list of accessible tables fields. This can also be obtained by
        /// inspecting the field descriptor returned by mapi_fetch_field().
        /// </summary>
        /// <param name="mid"></param>
        /// <returns></returns>
        public static string[] MapiFields(MapiConnection mid)
        {
            var pptr     = CMapiLib.mapi_fields(mid.Ptr);
            var ptr      = Marshal.ReadIntPtr(pptr);
            var exploded = new List <string>();

            do
            {
                exploded.Add(Marshal.PtrToStringAnsi(ptr));
                pptr = new IntPtr((int)pptr + IntPtr.Size);
                ptr  = Marshal.ReadIntPtr(pptr);
            } while (ptr != IntPtr.Zero);
            return(exploded.ToArray());
        }
예제 #6
0
 /// <summary>
 /// Send the Command to the database server represented by mid. 
 /// This function returns a query handle with which the results of the 
 /// query can be retrieved. The handle should be closed with mapi_close_handle(). 
 /// The command response is buffered for consumption, c.f. mapi\_fetch\_row().
 /// </summary>
 /// <param name="mapi"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuery(MapiConnection mapi, string command)
 {
     return new MapiHdl(CMapiLib.mapi_query(mapi.Ptr, command));
 }
예제 #7
0
 /// <summary>
 /// Similar to mapi_query_array(), except that the response of the
 /// server is not analyzed, but shipped immediately to the file indicated.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuickQueryArray(MapiConnection mid, string command, string[] args, FileStream fs)
 {
     return new MapiHdl(CMapiLib.mapi_quick_query_array(mid.Ptr, command, args, fs.SafeFileHandle));
 }
예제 #8
0
 /// <summary>
 /// Return the current value of the trace flag.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static int MapiGetTrace(MapiConnection mid)
 {
     return CMapiLib.mapi_get_trace(mid.Ptr);
 }
예제 #9
0
 /// <summary>
 /// Test availability of the server. Returns zero upon success.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiPing(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_ping(mapi.Ptr));
 }
예제 #10
0
 /// <summary>
 /// Close the current channel (if still open) and re-establish a fresh connection.
 /// This will remove all global session variables.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiReconnect(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_reconnect(mapi.Ptr)));
 }
예제 #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetDbName(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_get_dbname(mid.Ptr));
 }
예제 #12
0
 /// <summary>
 /// A limited number of tuples are pre-fetched after each execute().
 /// If maxrows is negative, all rows will be fetched before the application is
 /// permitted to continue. Once the cache is filled, a number of tuples are shuffled to
 /// make room for new ones, but taking into account non-read elements.
 /// Filling the cache quicker than reading leads to an error.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="maxrows"></param>
 /// <returns></returns>
 public static MapiMsg MapiCacheLimit(MapiConnection mid, int maxrows)
 {
     return(new MapiMsg(CMapiLib.mapi_cache_limit(mid.Ptr, maxrows)));
 }
예제 #13
0
 /// <summary>
 /// Send the Command to the database server replacing the placeholders (?) by the string arguments presented.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static MapiHdl MapiQueryArray(MapiConnection mid, string command, string[] args)
 {
     return(new MapiHdl(CMapiLib.mapi_query_array(mid.Ptr, command, args)));
 }
예제 #14
0
 /// <summary>
 /// Write the error message obtained from mserver to a file.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiMsg MapiExplain(MapiConnection mid, FileStream fs)
 {
     return(new MapiMsg(CMapiLib.mapi_explain(mid.Ptr, fs.SafeFileHandle)));
 }
예제 #15
0
 /// <summary>
 /// Set the autocommit flag (default is on).
 /// This only has an effect when the language is SQL.
 /// In that case, the server commits after each statement sent to the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="autocommit"></param>
 /// <returns></returns>
 public static MapiMsg MapiSetAutocommit(MapiConnection mid, int autocommit)
 {
     return(new MapiMsg(CMapiLib.mapi_setAutocommit(mid.Ptr, autocommit)));
 }
예제 #16
0
 /// <summary>
 /// Return a pointer to the last error message.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiErrorString(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_error_str(mid.Ptr)));
 }
예제 #17
0
 /// <summary>
 /// Return the last error code or 0 if there is no error.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static MapiMsg MapiError(MapiConnection mid)
 {
     return(new MapiMsg(CMapiLib.mapi_error(mid.Ptr)));
 }
예제 #18
0
 /// <summary>
 /// Move the query to a newly allocated query handle (which is returned).
 /// Possibly interact with the back-end to prepare the query for execution.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiPrepare(MapiConnection mid, string command)
 {
     return(new MapiHdl(CMapiLib.mapi_prepare(mid.Ptr, command)));
 }
예제 #19
0
 /// <summary>
 /// Send the request for processing and fetch a limited number of tuples
 /// (determined by the window size) to assess any erroneous situation.
 /// Thereafter, prepare for continual reading of tuples from the stream,
 /// until an error occurs. Each time a tuple arrives, the cache is shifted one.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="windowSize"></param>
 /// <returns></returns>
 public static MapiHdl MapiStreamQuery(MapiConnection mid, string command, int windowSize)
 {
     return(new MapiHdl(CMapiLib.mapi_stream_query(mid.Ptr, command, windowSize)));
 }
예제 #20
0
 /// <summary>
 /// Set the trace flag to monitor interaction with the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static MapiMsg MapiTrace(MapiConnection mid, int flag)
 {
     return(new MapiMsg(CMapiLib.mapi_trace(mid.Ptr, flag)));
 }
예제 #21
0
 /// <summary>
 /// Log the interaction between the client and server for offline inspection. 
 /// Beware that the log file overwrites any previous log. It is not intended for recovery.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static MapiMsg MapiTraceLog(MapiConnection mid, string filename)
 {
     return new MapiMsg(CMapiLib.mapi_trace_log(mid.Ptr, filename));
 }
예제 #22
0
 /// <summary>
 /// Return the current value of the trace flag.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static int MapiGetTrace(MapiConnection mid)
 {
     return(CMapiLib.mapi_get_trace(mid.Ptr));
 }
예제 #23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        /// <exception cref="MonetDbException"></exception>
        public static MapiHdl GetQueryHandle(MapiConnection connection, string query)
        {
            var queryHandle = MapiLib.MapiQuery(connection, query);

            DieQueryError(connection, queryHandle);

            return queryHandle;
        }
예제 #24
0
 /// <summary>
 /// Log the interaction between the client and server for offline inspection.
 /// Beware that the log file overwrites any previous log. It is not intended for recovery.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static MapiMsg MapiTraceLog(MapiConnection mid, string filename)
 {
     return(new MapiMsg(CMapiLib.mapi_trace_log(mid.Ptr, filename)));
 }
예제 #25
0
 /// <summary>
 /// Write the error message obtained from mserver to a file.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiMsg MapiExplain(MapiConnection mid, FileStream fs)
 {
     return new MapiMsg(CMapiLib.mapi_explain(mid.Ptr, fs.SafeFileHandle));
 }
예제 #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fnr"></param>
 /// <returns></returns>
 public static int MapiGetlen(MapiConnection mid, int fnr)
 {
     return(CMapiLib.mapi_get_len(mid.Ptr, fnr));
 }
예제 #27
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="fnr"></param>
 /// <returns></returns>
 public static int MapiGetlen(MapiConnection mid, int fnr)
 {
     return CMapiLib.mapi_get_len(mid.Ptr, fnr);
 }
예제 #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetDbName(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_dbname(mid.Ptr)));
 }
예제 #29
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetUser(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_get_user(mid.Ptr));
 }
예제 #30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiGetMotd(MapiConnection mid)
 {
     return(Marshal.PtrToStringAnsi(CMapiLib.mapi_get_motd(mid.Ptr)));
 }
예제 #31
0
 /// <summary>
 /// Move the query to a newly allocated query handle (which is returned). 
 /// Possibly interact with the back-end to prepare the query for execution.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiPrepare(MapiConnection mid, string command)
 {
     return new MapiHdl(CMapiLib.mapi_prepare(mid.Ptr, command));
 }
예제 #32
0
 /// <summary>
 /// Set the autocommit flag (default is on). 
 /// This only has an effect when the language is SQL. 
 /// In that case, the server commits after each statement sent to the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="autocommit"></param>
 /// <returns></returns>
 public static MapiMsg MapiSetAutocommit(MapiConnection mid, int autocommit)
 {
     return new MapiMsg(CMapiLib.mapi_setAutocommit(mid.Ptr, autocommit));
 }
예제 #33
0
 /// <summary>
 /// Send the Command to the database server replacing the placeholders (?) by the string arguments presented.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public static MapiHdl MapiQueryArray(MapiConnection mid, string command, string[] args)
 {
     return new MapiHdl(CMapiLib.mapi_query_array(mid.Ptr, command, args));
 }
예제 #34
0
 /// <summary>
 /// Return a list of accessible database tables.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string[] MapiTables(MapiConnection mid)
 {
     var pptr = CMapiLib.mapi_tables(mid.Ptr);
     var ptr = Marshal.ReadIntPtr(pptr);
     var exploded = new List<string>();
     do
     {
         exploded.Add(Marshal.PtrToStringAnsi(ptr));
         pptr = new IntPtr((int)pptr + IntPtr.Size);
         ptr = Marshal.ReadIntPtr(pptr);
     } while (ptr != IntPtr.Zero);
     return exploded.ToArray();
 }
예제 #35
0
 /// <summary>
 /// Close the current channel (if still open) and re-establish a fresh connection. 
 /// This will remove all global session variables.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiReconnect(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_reconnect(mapi.Ptr));
 }
예제 #36
0
 /// <summary>
 /// Similar to mapi_query_array(), except that the response of the
 /// server is not analyzed, but shipped immediately to the file indicated.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="args"></param>
 /// <param name="fs"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuickQueryArray(MapiConnection mid, string command, string[] args, FileStream fs)
 {
     return(new MapiHdl(CMapiLib.mapi_quick_query_array(mid.Ptr, command, args, fs.SafeFileHandle)));
 }
예제 #37
0
 /// <summary>
 /// Send the request for processing and fetch a limited number of tuples 
 /// (determined by the window size) to assess any erroneous situation. 
 /// Thereafter, prepare for continual reading of tuples from the stream, 
 /// until an error occurs. Each time a tuple arrives, the cache is shifted one.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="command"></param>
 /// <param name="windowSize"></param>
 /// <returns></returns>
 public static MapiHdl MapiStreamQuery(MapiConnection mid, string command, int windowSize)
 {
     return new MapiHdl(CMapiLib.mapi_stream_query(mid.Ptr, command, windowSize));
 }
예제 #38
0
 /// <summary>
 /// Test availability of the server. Returns zero upon success.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiPing(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_ping(mapi.Ptr)));
 }
예제 #39
0
 /// <summary>
 /// Set the trace flag to monitor interaction with the server.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="flag"></param>
 /// <returns></returns>
 public static MapiMsg MapiTrace(MapiConnection mid, int flag)
 {
     return new MapiMsg(CMapiLib.mapi_trace(mid.Ptr, flag));
 }
예제 #40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connection"></param>
 public static void CloseConnectionHandle(MapiConnection connection)
 {
     MapiLib.MapiDisconnect(connection);
     MapiLib.MapiDestroy(connection);
 }
예제 #41
0
 /// <summary>
 /// A limited number of tuples are pre-fetched after each execute(). 
 /// If maxrows is negative, all rows will be fetched before the application is 
 /// permitted to continue. Once the cache is filled, a number of tuples are shuffled to 
 /// make room for new ones, but taking into account non-read elements. 
 /// Filling the cache quicker than reading leads to an error.
 /// </summary>
 /// <param name="mid"></param>
 /// <param name="maxrows"></param>
 /// <returns></returns>
 public static MapiMsg MapiCacheLimit(MapiConnection mid, int maxrows)
 {
     return new MapiMsg(CMapiLib.mapi_cache_limit(mid.Ptr, maxrows));
 }
예제 #42
0
 /// <summary>
 /// Send the Command to the database server represented by mid.
 /// This function returns a query handle with which the results of the
 /// query can be retrieved. The handle should be closed with mapi_close_handle().
 /// The command response is buffered for consumption, c.f. mapi\_fetch\_row().
 /// </summary>
 /// <param name="mapi"></param>
 /// <param name="command"></param>
 /// <returns></returns>
 public static MapiHdl MapiQuery(MapiConnection mapi, string command)
 {
     return(new MapiHdl(CMapiLib.mapi_query(mapi.Ptr, command)));
 }
예제 #43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connection"></param>
 public static void CloseConnectionHandle(MapiConnection connection)
 {
     MapiLib.MapiDisconnect(connection);
     MapiLib.MapiDestroy(connection);
 }
예제 #44
0
 /// <summary>
 /// Terminate the session described by  mid if not already done so, and free all resources. 
 /// The handle cannot be used anymore.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiDestroy(MapiConnection mapi)
 {
     return new MapiMsg(CMapiLib.mapi_destroy(mapi.Ptr));
 }
예제 #45
0
 /// <summary>
 /// Return the last error code or 0 if there is no error.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static MapiMsg MapiError(MapiConnection mid)
 {
     return new MapiMsg(CMapiLib.mapi_error(mid.Ptr));
 }
예제 #46
0
 /// <summary>
 /// Return a pointer to the last error message.
 /// </summary>
 /// <param name="mid"></param>
 /// <returns></returns>
 public static string MapiErrorString(MapiConnection mid)
 {
     return Marshal.PtrToStringAnsi(CMapiLib.mapi_error_str(mid.Ptr));
 }
예제 #47
0
        /// <summary>
        /// 
        /// </summary>
        public void Open()
        {
            if (State == ConnectionState.Open)
                throw new MonetDbException("Connection already open.");

            _connection = MapiFactory.GetConnectionhandle(_database.ConnectionInfo);

            State = ConnectionState.Open;
        }
예제 #48
0
 /// <summary>
 /// Terminate the session described by  mid if not already done so, and free all resources.
 /// The handle cannot be used anymore.
 /// </summary>
 /// <param name="mapi"></param>
 /// <returns></returns>
 public static MapiMsg MapiDestroy(MapiConnection mapi)
 {
     return(new MapiMsg(CMapiLib.mapi_destroy(mapi.Ptr)));
 }