示例#1
0
        /// <summary>
        /// Executes a Query and returns the first int32 Value
        /// </summary>
        /// <param name="Query"></param>
        public int QueryCount(string Query)
        {
            DataTable result = new DataTable();

            mLastError = null;
            if (Query.Length == 0)
            {
                return(0);
            }

            Open();

            mAdapter = new MySqlDataAdapter();
            mAdapter.SelectCommand = new MySqlCommand(Query, mConnection);
            try {
                mAdapter.Fill(result);
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
                mLastError = ex;
                return(0);
            }

            ResultTable table = new ResultTable(result);

            if (table.Rows.Count == 0)
            {
                return(0);
            }

            return(table.Rows[0][0].GetInt32());
        }
示例#2
0
        /// <summary>
        /// Returns the MySQL LAST_INSERT_ID() Statement
        /// </summary>
        /// <returns></returns>
        public int GetLastInsertID()
        {
            ResultTable table = Query("SELECT LAST_INSERT_ID()");

            if (table.Rows.Count == 0)
            {
                return(-1);
            }

            return(table[0][0].GetInt());
        }