zoukankan      html  css  js  c++  java
  • 传入sql语句,执行完提取内容赋值到控件上

    class procedure DBTools.FillStrings(ComboBoxEh: TDBComboBoxEh; sql: string; Default: Boolean = False);
    var
    Q2: TADOQuery;
    begin
    ComboBoxEh.KeyItems.Clear;
    ComboBoxEh.Items.Clear;
    Q2 := ExecuteSelect(sql);
    if Q2.FieldCount = 1 then
    begin
    if Default then
    ComboBoxEh.Items.Append('全部');
    while not Q2.Eof do
    begin
    ComboBoxEh.Items.Append(Q2.Fields[0].AsString);
    Q2.Next;
    end;
    end;
    if Q2.FieldCount >= 2 then
    begin
    if Default then
    begin
    ComboBoxEh.KeyItems.Append(' ');
    ComboBoxEh.Items.Append('全部');
    end;
    while not Q2.Eof do
    begin
    ComboBoxEh.KeyItems.Append(Q2.Fields[0].AsString);
    ComboBoxEh.Items.Append(Q2.Fields[1].AsString);
    Q2.Next;
    end;
    end;
    Q2.Close;
    Q2.Free;
    if ComboBoxEh.DataSource = nil then
    ComboBoxEh.ItemIndex := 0;
    end;

    class procedure DBTools.FillStrings(ColumnEh: TColumnEh; sql: string; Default: Boolean = False);
    var
    Q2: TADOQuery;
    begin
    ColumnEh.KeyList.Clear;
    ColumnEh.PickList.Clear;
    Q2 := ExecuteSelect(sql);
    if Q2.FieldCount = 1 then
    begin
    if Default then
    ColumnEh.PickList.Append('全部');
    while not Q2.Eof do
    begin
    ColumnEh.PickList.Append(Q2.Fields[0].AsString);
    Q2.Next;
    end;
    end;
    if Q2.FieldCount >= 2 then
    begin
    if Default then
    begin
    ColumnEh.KeyList.Append(' ');
    ColumnEh.PickList.Append('全部');
    end;
    while not Q2.Eof do
    begin
    ColumnEh.KeyList.Append(Q2.Fields[0].AsString);
    ColumnEh.PickList.Append(Q2.Fields[1].AsString);
    Q2.Next;
    end;
    end;
    Q2.Close;
    Q2.Free;
    end;

  • 相关阅读:
    hdu 5734 Acperience
    报错解决
    测试代码出错
    fast rcnn训练自己数据小结
    top命令
    读csv文件
    计算机的屏幕坐标
    用virtualenv构建一个新的python环境,这个新的环境在这个创建的文件夹下
    python tips
    将目录下所有文件名修改为统一格式
  • 原文地址:https://www.cnblogs.com/zyb2016/p/6077495.html
Copyright © 2011-2022 走看看