第一问: if GRID.datasource.dataset.Modified then showmessage('had Modified') else showmessage('Has not Modified');如果是对数据库操作,DBGRID会方便点,另外,第三方控件InfoPower的TwwDBGrid会更好用。
在那儿再送20分? 我不明白你的这句话"要考虑网络上有其它用户也在使用此软件.后台用SQL SERVER.我不想让用户一打开DBGRID就占用后台此数据库.",可不可以说明白点? 假设你ADOQUERY Component的所有其它属性都设置正确,并且你的ADOConnection 为Connection1 "新增"按钮: ........ try if Connection1.InTransaction then Connection1.RollbackTrans; Connection1.BeginTrans; with ADOQUERY do begin Active := False; Connection := Connection1 SQL.Add('Select XX from XX where XX'); Active := True; append; end; except Connection1.RollbackTrans; ...... end;
"提交"按钮: ...... ADOQUERY.post; if Connection1.InTransaction then Connection1.CommitTrans; ....... end;
if GRID.datasource.dataset.Modified then
showmessage('had Modified')
else
showmessage('Has not Modified');如果是对数据库操作,DBGRID会方便点,另外,第三方控件InfoPower的TwwDBGrid会更好用。
我不明白你的这句话"要考虑网络上有其它用户也在使用此软件.后台用SQL SERVER.我不想让用户一打开DBGRID就占用后台此数据库.",可不可以说明白点?
假设你ADOQUERY Component的所有其它属性都设置正确,并且你的ADOConnection 为Connection1
"新增"按钮:
........
try
if Connection1.InTransaction then
Connection1.RollbackTrans;
Connection1.BeginTrans;
with ADOQUERY do
begin
Active := False;
Connection := Connection1
SQL.Add('Select XX from XX where XX');
Active := True;
append;
end;
except
Connection1.RollbackTrans;
......
end;
"提交"按钮:
......
ADOQUERY.post;
if Connection1.InTransaction then
Connection1.CommitTrans;
.......
end;