DesktopHelper.DB.SqlAction.StringQuery C# (CSharp) Method

StringQuery() public method

执行查询SQL,返回查询结果的首行首列
public StringQuery ( string sql, SQLiteParameter parameters ) : string
sql string sql语句
parameters System.Data.SQLite.SQLiteParameter 参数
return string
        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;
        }

Usage Example

 public string GetDefaultSearch()
 {
     string result = string.Empty;
     try
     {
         string sqlString = @"select Value  from t_config where Name = 'DefaultSearch'";
         SqlAction action = new SqlAction();
         result = action.StringQuery(sqlString, null);
     }
     catch
     {
     }
     return result;
 }