rt,怎么在delphi同一界面下显示不同报表的内容?
比如我有表a(id,姓名,性别)
表b(id,年龄),
给用户一个combobox,选择要查看的表a或b
选a查看a表内容,选b查看b表内容
需要怎么做好一些?
谢谢各位
比如我有表a(id,姓名,性别)
表b(id,年龄),
给用户一个combobox,选择要查看的表a或b
选a查看a表内容,选b查看b表内容
需要怎么做好一些?
谢谢各位
解决方案 »
- 生成参数SQL . 顺便散分.
- DELPHI中如何内嵌WORD
- windows下,delphi中,如何获取文件的“修订版号码”
- 关于调用自动化(COM)中MDI窗体的问题,请能帮我解决2500分相送!!!付现金也可以只要能帮我解决,您开个价,只要我能接受,一定照付!
- 求助高手! Delphi 螢幕小鍵盤
- 能比较一下vcl和COM的异同
- 设计数据表时,采中文列名会引起数据库运行不稳定吗
- delphi中什么控件可以读出QRP后缀的文件?分数少,还望回答
- 关于Servers页面的控件
- 为什么DELPHI的DBGRID没有检索出数据时还是有一条空记录呢?如何去掉?
- 使用工程组时,断点总失效是为什么
- 新手 求解决个错误!
看你给出来的例子,怎么觉得这两个表应该显示在一个报表中呢,用关联查询就行了.
query和DBgrid动态赋值也可以用两个DBgrid,选查看什么,就将对应的DBgrid的Visible设为True
比如我有表a(id,姓名,性别)
表b(id,年龄),
给用户一个 combobox,选择要查看的表a或b
选a查看a表内容,选b查看b表内容
需要怎么做好一些?
谢谢各位假设是通过 点击按钮Button1来查询 ADOQuery1 关联数据
}
procedure TForm1.Button1Click(Sender: TObject);
begin
if ADOQuery1.Active then
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:=' ' ;
if combobox1.ItemIndex=0 then //a
ADOQuery1.SQL.Text:=' select * from a'
else if combobox1.ItemIndex=1 then //b
ADOQuery1.SQL.Text:=' select * from b' ;
ADOQuery1.Open;
end;
如果我有10个表,写10个dbgrid?每次9个不显示?
inner join b
on a.id = b.id
DBGrid包含a,b的所有字段Button1的onclick事件中判断combobox是a还是b,将DBGrid中b,a的字段的Visible设为falseDBGrid1.Columns.Items[i].Visible := false;
var
temp:TListItem;
listview1.items.clear;
if combobox1.ItemIndex=0 then
begin
ssql:='select * from a ';
end
else if combobox1.ItemIndex=1 then
begin
ssql:='select * from 6 ';end;
with adoquery1 do
begin
close;
sql.clear;
sql.add(ssql);
open;
while not eof do
begin
temp:=listview1.items.add;
if combobox1.ItemIndex=0 then
begin
temp.caption:=fieldbyname('id').asstring;
temp.SubItems.Add(fieldbyname('name').asstring);
temp.SubItems.Add(fieldbyname('sex').asstring);
end
else if combobox1.ItemIndex=1 then
begin
temp.caption:=fieldbyname('id').asstring;
temp.SubItems.Add(fieldbyname('age').asstring); end;
next;
end;
end;
var
temp:TListItem;
listview1.items.clear;
if combobox1.ItemIndex=0 then
begin
ssql:='select * from a ';
end
else if combobox1.ItemIndex=1 then
begin
ssql:='select * from b ';end;
with adoquery1 do
begin
close;
sql.clear;
sql.add(ssql);
open;
while not eof do
begin
temp:=listview1.items.add;
if combobox1.ItemIndex=0 then
begin
temp.caption:=fieldbyname('id').asstring;
temp.SubItems.Add(fieldbyname('name').asstring);
temp.SubItems.Add(fieldbyname('sex').asstring);
end
else if combobox1.ItemIndex=1 then
begin
temp.caption:=fieldbyname('id').asstring;
temp.SubItems.Add(fieldbyname('age').asstring); end;
next;
end;
end;
有10个表 就用10个IF 或者CASE什么的
with ADOQuery1 do
begin
Close;
SQL.Text := 'select top 1 * from '+ComboBox1.Text+' where 1 = 1';
Open;
end;