zoukankan      html  css  js  c++  java
  • uniGUI之FDQuery(28)

    1]基本设置FDQuery1.Connection
    2]执行查询SQL语句
    3]执行 非查询SQL语句
    4]返回所有数据 和所有 列名


    1]基本设置FDQuery1.Connection

     一定要 放一个  FDPhysSQLiteDriverLink1到ServerModule上

    // uses FireDAC.Phys.SQLite 之后, 可不用添加 TFDPhysSQLiteDriverLink           //访问SQLite  文件数据库
      FDQuery1.Connection := UniMainModule.FDConnection1;
    
      UniMainModule.FDConnection1.LoginPrompt := false; // 取消登录提示框
      UniMainModule.FDConnection1.Open('DriverID=SQLite;Database=test1.Sqlite3');

    2]执行查询SQL语句

    FDQuery1.Open('select id,name,info from atb');

    3]执行 非查询SQL语句

    FDQuery1.ExecSQL('INSERT INTO atb VALUES( (select max(id)+1 from atb),''aName'',''aInfo'')');


    4]返回所有数据 和所有 列名, 生成网页格式,方便导出数据

       procedure UniDBGridToHTML(aFDquery :TFDQuery;aHTMLFileName:string);
    var
      aHTMLtext: TstringList;
       j: integer;
    begin
      aHTMLtext := TstringList.Create;
      aHTMLtext.Add
        ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  ' +
        '<html>   <head>    <title></title>   </head>  ' +
        '  <body>  <table border=".5pt solid windowtext;"; > ' +
        ' <col width=72 span=3 style='' 54pt''>');
    
      aHTMLtext.Add(' <tr > ');
        for j := 1 to aFDquery.FieldCount do
        begin
          aHTMLtext.Add('<td>');
          aHTMLtext.Add(aFDquery.Fields.FieldByNumber(j).FieldName);   //  列 名
          aHTMLtext.Add('</td>');
        end;
      aHTMLtext.Add(' </tr> ');
    
      aFDquery.First;
      while not(aFDquery.Eof) do
      begin
        aHTMLtext.Add(' <tr  > ');
    
        for j := 1 to aFDquery.FieldCount do
        begin
          aHTMLtext.Add('<td>');
          aHTMLtext.Add(aFDquery.Fields.FieldByNumber(j).AsString);   //  所有 值
          aHTMLtext.Add('</td>');
        end;
        aHTMLtext.Add(' </tr> ');
    
        aFDquery.Next;
      end;
    
      aHTMLtext.Add('</table>  </body>  </html> ');
      aHTMLtext.SaveToFile(aHTMLFileName);
      aHTMLtext.Free;
    end;
    procedure TMainForm.UniButton1Click(Sender: TObject);
    begin
      UniDBGridToHTML(FDquery1,'aa.html');//调用
    end;
  • 相关阅读:
    为cocos2d-x实现安卓输入框。非全屏,无dialog,绑定到lua
    自己动手,丰衣足食。普通键盘实现键盘宏(Windows和Mac版)
    go语言使用protobuf
    go语言使用redis —— redigo
    go语言实现线程池
    go语言实现的目录共享程序
    ss
    BST
    堆排序—最大优先级队列
    STL_Vector
  • 原文地址:https://www.cnblogs.com/tulater/p/12295499.html
Copyright © 2011-2022 走看看