delphi的example: { Try to open Table1 with Exclusive True }{ First, close Table1 } Table1.Active := False; repeat { until successful or Cancel button is pressed } try Table1.Exclusive := True; { See if it will open } Table1.Active := True; Break; { If no error, exit the loop } except on EDatabaseError do { Ask if it is OK to retry. If it isn抰, reraise to abort } if Application.MessageBox( 'Could not open Table1 exclusively - Try again?', 'Open Error', MB_OKCANCEL + MB_DEFBUTTON1) <> IDOK then raise; { Otherwise resume the repeat loop } end; until False;
人家说的是delphi
bcb中是双引号,delphi中是单引号
{ Try to open Table1 with Exclusive True }{ First, close Table1 }
Table1.Active := False;
repeat { until successful or Cancel button is pressed }
try
Table1.Exclusive := True; { See if it will open }
Table1.Active := True;
Break; { If no error, exit the loop }
except
on EDatabaseError do
{ Ask if it is OK to retry. If it isn抰, reraise to abort }
if Application.MessageBox(
'Could not open Table1 exclusively - Try again?', 'Open Error',
MB_OKCANCEL + MB_DEFBUTTON1) <> IDOK then
raise;
{ Otherwise resume the repeat loop }
end;
until False;