ExecuteDataTable() public method

执行一个查询语句,返回一个包含查询结果的DataTable
public ExecuteDataTable ( string sql, SQLiteParameter parameters ) : DataTable
sql string 要执行的查询语句
parameters System.Data.SQLite.SQLiteParameter 执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准
return System.Data.DataTable
        /// <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
            {
            }
            return(data);
        }
        /// <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
            {
            }
            return(result);
        }