我有两张表(student表、accounts表),我对student表中部分记录的student_money增加金额,同时,增加金额的记录同时加入到accounts表中,程序如下,但执行的速度相当慢,如何解决?
while not mydb.ADOTable_student.Eof do
begin
mydb.ADOTable_student.Edit;
mydb.ADOTable_student.FieldByName('student_money').AsFloat:=mydb.ADOTable_student.FieldByName('student_money').AsFloat+strtofloat(student_money.Text)*money;
mydb.ADOTable_student.Post;
mydb.ADOTable_student.Refresh; mydb.ADOTable_accounts.Insert;
mydb.ADOTable_accounts.fieldbyname('student_card').Asstring:=mydb.ADOTable_student.fieldbyname('student_card').AsString;
mydb.ADOTable_accounts.FieldByName('student_money').AsFloat:=strtofloat(student_money.Text)*money;
mydb.ADOTable_accounts.FieldByName('money_about').AsString:=Money_about;
mydb.ADOTable_accounts.FieldByName('sys_name').AsString:='sys';
mydb.ADOTable_accounts.post;
mydb.ADOTable_accounts.refresh; mydb.ADOTable_student.Next;
end;
while not mydb.ADOTable_student.Eof do
begin
mydb.ADOTable_student.Edit;
mydb.ADOTable_student.FieldByName('student_money').AsFloat:=mydb.ADOTable_student.FieldByName('student_money').AsFloat+strtofloat(student_money.Text)*money;
mydb.ADOTable_student.Post;
mydb.ADOTable_student.Refresh; mydb.ADOTable_accounts.Insert;
mydb.ADOTable_accounts.fieldbyname('student_card').Asstring:=mydb.ADOTable_student.fieldbyname('student_card').AsString;
mydb.ADOTable_accounts.FieldByName('student_money').AsFloat:=strtofloat(student_money.Text)*money;
mydb.ADOTable_accounts.FieldByName('money_about').AsString:=Money_about;
mydb.ADOTable_accounts.FieldByName('sys_name').AsString:='sys';
mydb.ADOTable_accounts.post;
mydb.ADOTable_accounts.refresh; mydb.ADOTable_student.Next;
end;
解决方案 »
- delphi Unit1.pas(101): Undeclared identifier: 'F1CellFormat'
- 程序如何接受存储过程的错误返回??
- 关于拖动问题?
- 年终奖就要发了。
- 申请(game,图形处理/多媒体)版的版主,大家支持
- 来者有分:报表打印问题
- 删除文件到回收站的问题
- ADO控件怎么用??和普通的数据控件有什么区别?
- 如何验证一个时间(如20:12:12)或者日期(02-2-2)的合法性?
- 急急急呀!!各位高手请赶快相救呀,我怎么通过程序来控制midiaplay的播放呀,大家给我好的建议也好。
- 抽到一等奖,买一件西服送音箱+功放+VCD,该不该去买?会不会有诈?帮我看看
- 帮帮我啊。我在等..
mydb.ADOTable_accounts.DisalbeControls;mydb.ADOTable_student.Edit;
while not mydb.ADOTable_student.Eof do
begin
mydb.ADOTable_student.FieldByName('student_money').AsFloat:=mydb.ADOTable_student.FieldByName('student_money').AsFloat+strtofloat(student_money.Text)*money;
mydb.ADOTable_student.Post; mydb.ADOTable_accounts.Insert;
mydb.ADOTable_accounts.fieldbyname('student_card').Asstring:=mydb.ADOTable_student.fieldbyname('student_card').AsString;
mydb.ADOTable_accounts.FieldByName('student_money').AsFloat:=strtofloat(student_money.Text)*money;
mydb.ADOTable_accounts.FieldByName('money_about').AsString:=Money_about;
mydb.ADOTable_accounts.FieldByName('sys_name').AsString:='sys';
mydb.ADOTable_accounts.post; mydb.ADOTable_student.Next;
end;
enableControls;
adotable_student.enableControls;
mydb.ADOTable_accounts.enableControls;
enableControls;
数据库的STUDENT表作个触发器呀....碰到Modify时候触发修改account表..
速度又快.也省事..