{$IFDEF sql}//在sql server数据库语句中进行判断
with dm.ADOQuery1 dobegin
Close;
SQL.Clear;
SQL.Add(' SELECT 1 FROM SYSOBJECTS T1 INNER JOIN SYSCOLUMNS T2 ON T1.ID=T2.ID WHERE T1.NAME=''czy'' AND T2.NAME=''czyjy'' ');
Open;
if Eof then
try
with dm.quetemp do
begin
Close; sql.Clear;
SQL.Add(' alter table czy add czyjy bit ');
ExecSQL;
Close; sql.Clear;
SQL.Add('update czy set czyjy=0');
ExecSQL;
end;
except
end;
end;
{$ENDIF}
{$IFDEF access}//在access数据库中进行判断
with dm.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' SELECT * FROM czy');
Open;
for i := 0 to Fields.count-1 do
begin
if Fields[I].FieldName = 'czyjy' then
begin
m := 0;
Break;
end
else
m := 1 ;
end;
end;
if m = 1 then
try
with dm.quetemp do
begin
Close; sql.Clear;
SQL.Add(' alter table czy add czyjy bit ');
ExecSQL;
Close; sql.Clear;
SQL.Add('update czy set czyjy=0');
ExecSQL;
end;
except
end;
{$ENDIF}