Ejemplo n.º 1
0
        /// <summary>
        /// 执行查询SQL,返回受影响行数
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public int IntQuery(string sql, SQLiteParameter[] parameters)
        {
            int result = 0;

            try
            {
                SQLiteDBHelper dbHelper = new SQLiteDBHelper();
                result = dbHelper.ExecuteNonQuery(sql, parameters);
            }
            catch (Exception exMsg)
            {
                //Log.Error("ExecuteNonQuery出错:" + exMsg.ToString());
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行查询SQL,返回查询结果表
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns>查询结果表</returns>
        public DataTable DataTableQuery(string sql, SQLiteParameter[] parameters)
        {
            DataTable data = new DataTable();

            try
            {
                SQLiteDBHelper dbHelper = new SQLiteDBHelper();
                data = dbHelper.ExecuteDataTable(sql, parameters);
            }
            catch (Exception ex)
            {
                //Log.Error("DataTableQuery出错:" + ex.ToString());
            }
            return(data);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 执行查询SQL,返回查询结果的首行首列
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数</param>
        /// <returns></returns>
        public string StringQuery(string sql, SQLiteParameter[] parameters)
        {
            string result = string.Empty;

            try
            {
                SQLiteDBHelper dbHelper = new SQLiteDBHelper();
                DataTable      data     = dbHelper.ExecuteDataTable(sql, parameters);
                if (data != null && data.Rows.Count > 0)
                {
                    result = data.Rows[0][0].ToString();
                }
            }
            catch (Exception ex)
            {
                //Log.Error("DataTableQuery出错:" + ex.ToString());
            }
            return(result);
        }