zoukankan      html  css  js  c++  java
  • LiteQuery MAX(Integer)、MAX(String) 判断是否返回值

    unit Unit6;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, LiteCall, LiteConsts, Vcl.StdCtrls,
      Data.DB, MemDS, DBAccess, LiteAccess;
    
    type
      TForm6 = class(TForm)
        LiteConnection1: TLiteConnection;
        LiteQuery1: TLiteQuery;
        Button1: TButton;
        LiteQuery2: TLiteQuery;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form6: TForm6;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm6.Button1Click(Sender: TObject);
    begin
      LiteQuery1.Close;
      LiteQuery1.SQL.Text := 'SELECT MAX(age) AS max_age FROM max_test';
      LiteQuery1.Open;
      if LiteQuery1.IsEmpty then
      begin
        ShowMessage('IsEmpty');
      end else begin
        ShowMessage('非空');
        ShowMessage(LiteQuery1.FieldByName('max_age').AsString);
        if LiteQuery1.FieldByName('max_age').IsNull then
        begin
          ShowMessage('为null');
        end else begin
          ShowMessage(LiteQuery1.FieldByName('max_age').AsString);
        end;
      end;
    end;
    
    procedure TForm6.Button2Click(Sender: TObject);
    begin
      LiteQuery2.Close;
      LiteQuery2.SQL.Text := 'SELECT MAX(name) AS max_name FROM max_test';
      LiteQuery2.Open;
      if LiteQuery2.IsEmpty then
      begin
        ShowMessage('IsEmpty');
      end else begin
        ShowMessage('非空');
        ShowMessage(LiteQuery2.FieldByName('max_name').AsString);
        if LiteQuery2.FieldByName('max_name').IsNull then
        begin
          ShowMessage('为null');
        end else begin
          ShowMessage(LiteQuery2.FieldByName('max_name').AsString);
        end;
    
    
      end;
    end;
    
    end.
  • 相关阅读:
    InjectAPC全部项目(Win32和Win64位)
    Codeforces Round #377 (Div. 2)
    Codeforces Canada Cup 2016
    UVa 1395 (最小生成树)
    空间表SpaceList
    线程中的临界区的应用
    【题解】狼和羊-C++
    【基础算法-树状数组】入门-C++
    【题解】在你窗外闪耀的星星-C++
    【题解】[NOIP模拟题]我要的幸福-C++
  • 原文地址:https://www.cnblogs.com/del88/p/7397171.html
Copyright © 2011-2022 走看看