R
redsuns2001
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么在下面的事件中,有时会出现“无法更新;当前被锁定”的信息,有时又正常的呢?
if DBGrid1.SelectedRows.Count <= 0 then
Exit;
Self.Enabled:=false;
DBGrid1.DataSource.DataSet.DisableControls;
try
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
DBGrid1.DataSource.DataSet.GotoBookmark(pointer(DBGrid1.SelectedRows.Items));
if IsMobile(Trim(DBGrid1.DataSource.DataSet.FieldByName('手机').AsString)) then
begin
Application.ProcessMessages;
MainForm.N28.Click; //调用某事件,此事件会返回SendStatus
if SendStatus=0 then
TrueFalse:='true'
else
TrueFalse:='false';
ADOQuery7.Close; //将上面的结果插入表中
ADOQuery7.SQL.Clear;
ADOQuery7.SQL.Add('insert into 生日表(编号,姓名,手机,生日时间,厂家,型号,车牌号码,发送时间,类型,状态) values('
+ADOQuery2.FieldByName('编号').AsString+','
+#39+ADOQuery2.FieldByName('姓名').AsString+#39+','
+#39+ADOQuery2.FieldByName('手机').AsString+#39+','
+#39+ADOQuery2.FieldByName('生日时间').AsString+#39+','
+#39+ADOQuery2.FieldByName('厂家').AsString+#39+','
+#39+ADOQuery2.FieldByName('型号').AsString+#39+','
+#39+ADOQuery2.FieldByName('车牌号码').AsString+#39+','
+#39+DateTimeToStr(Now)+#39+','
+#39+'新历'+#39+','+TrueFalse+')');
ADOQuery7.ExecSQL;
ADOQuery2.Delete; // 此DBGrid1 所对应的DataSet
end;
end;
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
except
on E: Exception do
begin
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
MessageBox(Handle,PChar(E.Message),'提示',MB_ICONWARNING);
Exit;
end;
end;
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
其中DBGrid1和ADOQuery2是指向同一个表
if DBGrid1.SelectedRows.Count <= 0 then
Exit;
Self.Enabled:=false;
DBGrid1.DataSource.DataSet.DisableControls;
try
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
DBGrid1.DataSource.DataSet.GotoBookmark(pointer(DBGrid1.SelectedRows.Items));
if IsMobile(Trim(DBGrid1.DataSource.DataSet.FieldByName('手机').AsString)) then
begin
Application.ProcessMessages;
MainForm.N28.Click; //调用某事件,此事件会返回SendStatus
if SendStatus=0 then
TrueFalse:='true'
else
TrueFalse:='false';
ADOQuery7.Close; //将上面的结果插入表中
ADOQuery7.SQL.Clear;
ADOQuery7.SQL.Add('insert into 生日表(编号,姓名,手机,生日时间,厂家,型号,车牌号码,发送时间,类型,状态) values('
+ADOQuery2.FieldByName('编号').AsString+','
+#39+ADOQuery2.FieldByName('姓名').AsString+#39+','
+#39+ADOQuery2.FieldByName('手机').AsString+#39+','
+#39+ADOQuery2.FieldByName('生日时间').AsString+#39+','
+#39+ADOQuery2.FieldByName('厂家').AsString+#39+','
+#39+ADOQuery2.FieldByName('型号').AsString+#39+','
+#39+ADOQuery2.FieldByName('车牌号码').AsString+#39+','
+#39+DateTimeToStr(Now)+#39+','
+#39+'新历'+#39+','+TrueFalse+')');
ADOQuery7.ExecSQL;
ADOQuery2.Delete; // 此DBGrid1 所对应的DataSet
end;
end;
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
except
on E: Exception do
begin
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
MessageBox(Handle,PChar(E.Message),'提示',MB_ICONWARNING);
Exit;
end;
end;
DBGrid1.DataSource.DataSet.EnableControls;
Self.Enabled:=true;
Edit2.SetFocus;
DBGrid1.SetFocus;
其中DBGrid1和ADOQuery2是指向同一个表