procedure GeneralcmbBox(AcmbBox:TComboBox;AstrSQL:string);
begin
AcmbBox.Clear;
with TADOQuery.Create do
begin
TRY
if ConnectionString = '' then CoonectionString := ADOCnStr;//Const or public Var
Close;
SQL.Text := AstrSQL;
Open;
if IsEmpty then Exit;
while not Eof do
begin
AcmbBox.Items.Add(Fields[0].AsString);
Next;
end;
Close;
FINALLY
Free;
END;
end;
end;
begin
AcmbBox.Clear;
with TADOQuery.Create do
begin
TRY
if ConnectionString = '' then CoonectionString := ADOCnStr;//Const or public Var
Close;
SQL.Text := AstrSQL;
Open;
if IsEmpty then Exit;
while not Eof do
begin
AcmbBox.Items.Add(Fields[0].AsString);
Next;
end;
Close;
FINALLY
Free;
END;
end;
end;
解决方案 »
- DBGrid列排序的问题--马上结贴
- Function声明的简单问题.
- 状态栏?
- delphi中怎么编程实现关闭电脑扬声器的声音?
- 请各位高手帮我看看SQL语句的书写格式有什麽问题?
- 在个公司一年多了!,工资还是一年前的700,我不想干了!因为穷!我不得不选择离开了!
- 问一个关于spcomm有时候没有获取到返回数据的问题
- dbgrideh怎样复制一行数据,但不复制标题
- 高分求购一份文档(数据库开发文档例子)
- 我下了DELPHI的补丁包和ADO的补丁,可我都装不上!(注册码错误),请问有什么解决的办法?
- 关于触发器的问题
- 我用delphi往oracle數據庫表里插字段時,執行insert語句希望 有時要執行觸發器,有時不執行觸發器 . 怎麼實現??
begin
AcmbBox.Clear;
with TADOQuery.Create do
begin
TRY
if ConnectionString = '' then CoonectionString := ADOCnStr;//Const or public Var
Close;
SQL.Text := AstrSQL;
Open;
if IsEmpty then Exit;
while not Eof do
begin
AcmbBox.Items.Add(Fields[0].AsString);
Next;
end;
Close;
FINALLY
Free;
END;
end;
end;
另外如果希望该函数的内涵再大点,则只要将ADOQUERY的连接字符串connectionstring作为一个参数就行,其它情况根据需要增改参数即可。
基本思路同楼上的smallbridge