高手请教,我的程序在FormShow中的执行,我需要根据ComboBox1的Text变化选择查询显示相应的数据值可是只能显示一条在变换ComboBox1的Text的内容,其他的Edit.text没有任何变化!!郁闷!!!!谢谢指教!!!vara : string;
begin
Edit9.Text := Form1.ComboBox1.Text;
DS := TSQLDataset.Create(nil);
DS.SQLConnection := SQLConnection1;
DS.CommandType := ctQuery;
DS.CommandText :='select * from cpdj';
try
DS.Open;
while not DS.Eof do
begin
ComboBox1.Items.Add(DS.FieldByName('cname').AsString);
ComboBox1.ItemIndex := 0;
DS.Next;
end;
begin
a := ComboBox1.Text;
DS := TSQLDataset.Create(nil);
DS.SQLConnection := SQLConnection1;
DS.CommandType := ctQuery;
DS.CommandText :='select cid from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit2.Text :=DS.FieldByName('cid').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select clx from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit3.Text :=DS.FieldByName('clx').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select cxh from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit4.Text :=DS.FieldByName('cxh').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select ghsname from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit4.Text :=DS.FieldByName('ghsname').AsString ;
end;
end;
finally
DS.Free; //当数据库操作完成后释放。
end;
begin
self.DateTimePicker1.datetime :=now;
end;
end;
begin
Edit9.Text := Form1.ComboBox1.Text;
DS := TSQLDataset.Create(nil);
DS.SQLConnection := SQLConnection1;
DS.CommandType := ctQuery;
DS.CommandText :='select * from cpdj';
try
DS.Open;
while not DS.Eof do
begin
ComboBox1.Items.Add(DS.FieldByName('cname').AsString);
ComboBox1.ItemIndex := 0;
DS.Next;
end;
begin
a := ComboBox1.Text;
DS := TSQLDataset.Create(nil);
DS.SQLConnection := SQLConnection1;
DS.CommandType := ctQuery;
DS.CommandText :='select cid from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit2.Text :=DS.FieldByName('cid').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select clx from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit3.Text :=DS.FieldByName('clx').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select cxh from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit4.Text :=DS.FieldByName('cxh').AsString ;
ds.Next;
end;
DS.Close;
DS.CommandText :='select ghsname from cpdj where cname='+quotedstr(a)+'';
DS.Open;
while not DS.Eof do
begin
edit4.Text :=DS.FieldByName('ghsname').AsString ;
end;
end;
finally
DS.Free; //当数据库操作完成后释放。
end;
begin
self.DateTimePicker1.datetime :=now;
end;
end;
解决方案 »
- 请教关于发送打印机指令问题。。。
- TEdit和TComboBox都是从TControl下继承下来的,如何判断2个类他们具有相同的祖先
- 简单问题!!
- 求救? 以Delphi5开发的政府专用发票打印系统中的报表存在问题.
- 再提关于窗口(Form)Canvas的刷新的问题!
- printer.canvas.TextOut(X,Y,Text)中X,Y的单位是什么?和象素的关系?
- 简单问题:怎样在c:\盘中查找指定类型的所有(如:*.txt)文件?(在线)
- 关于能进行“网络会议”软件有关问题的寻问(SOS)
- 谁能翻译一下!?
- 请教高手:如何在程序中判断一个数据库(dbf,access)正在被别的程序使用?
- 编译环境问题?请进
- 怎样制作有图表的报表?
while not DS.Eof do
begin
edit3.Text :=DS.FieldByName('clx').AsString ; //这样只显示查询出来的结果集的最后一条记录
ds.Next;
end;