注册 登录
编程论坛 Delphi论坛

我修改完数据,但DBGRID里没显示出我修改完的结构,请问怎么刷新数据

chianti1010 发布于 2006-05-12 15:22, 840 次点击

adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.add('update T_teacher set Tdirection='''+edit1.Text+'''');
adoquery2.SQL.add('update T_teacher set Tsort='''+edit2.Text+'''');
adoquery2.SQL.add('update T_teacher set Tdoctor='''+edit3.Text+'''');
adoquery2.SQL.add('update T_teacher set Tmaster='''+edit5.Text+'''');
adoquery2.SQL.add('update T_teacher set Tdate='''+edit4.Text+'''');
adoquery2.SQL.Add('select T_teacher.* from T_teacher,T_member where T_teacher.Tmcode=T_member.Mcode');
adoquery2.ExecSQL;
adoquery2.Active:=false;
adoquery2.Active:=true;

4 回复
#2
xu20002006-05-13 09:15
adoquery2.ExecSQL;
adoquery2.Active:=false;
adoquery2.Active:=true;
为什么要这么写?
adoquery2.open; 不行吗
#3
j6682006-12-21 00:21
adoquery2.Active:=false;
adoquery2.Active:=true;
这样不能的。。
改成这样:用adocommand来更新数据

begin
//插入数据
adocommand1.CommandText:='insert into 月份([编号],[名称]) values('''+edit2.text+''','''+edit3.Text+''')';
adocommand1.Execute;
//刷新表
adoquery1.Close;
adoquery1.sql.Clear;
adoquery1.sql.add('select * from 月份');
adoquery1.open;
end;
#4
j6682006-12-21 00:22
2楼你这样会出错的。。
#5
nongen2006-12-21 09:12
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.add('update T_teacher set Tdirection='''+edit1.Text+'''');
adoquery2.SQL.add('update T_teacher set Tsort='''+edit2.Text+'''');
adoquery2.SQL.add('update T_teacher set Tdoctor='''+edit3.Text+'''');
adoquery2.SQL.add('update T_teacher set Tmaster='''+edit5.Text+'''');
adoquery2.SQL.add('update T_teacher set Tdate='''+edit4.Text+'''');
adoquery2.ExecSQL;
-----------这样分开来就没事了。
adoquery2.sql.clear;
adoquery2.SQL.Add('select T_teacher.* from T_teacher,T_member where T_teacher.Tmcode=T_member.Mcode');
adoquery2.open;
--------------------------

[此贴子已经被作者于2006-12-21 17:30:33编辑过]

1