原链接:https://www.cnblogs.com/lantianhf/p/6084155.html
{数据库操作}
function TDataModule1.GetSD(Sid: Integer;ppn:Integer):string;
begin
try
with WSD do
begin
Close;
SQL.Clear ;
SQL.Add('select * from led_kongtiao_View');
SQL.Add(' where ITEM_ID='+inttostr(Sid));
Open;
if RecordCount>0 then
begin
if (FieldByName('ITEM_VALUE').IsNull) or (FieldByName('ITEM_VALUE').AsString='') then
SD[ppn]:='---'
else
SD[ppn]:=Dl(FieldByName('ITEM_VALUE').AsFloat)+'%';
end;
end;
except
on E: Exception do
Result := E.Message;
end;
end;
{判断数据库操作是否成功}
function Tledform.GetDB: string;
var
str:string;
begin
Result:='';
str:=DataModule1.GetSD(1,1);
if str<>'' then
{重新连接数据库,具体可根据自己的实际情况来处理!}
DataModule1.timer.enable:=true;
else
{正常连接数据库,无操作}
end;
{数据库操作}
function TDataModule1.GetSD(Sid: Integer;ppn:Integer):string;
begin
try
with WSD do
begin
Close;
SQL.Clear ;
SQL.Add('select * from led_kongtiao_View');
SQL.Add(' where ITEM_ID='+inttostr(Sid));
Open;
if RecordCount>0 then
begin
if (FieldByName('ITEM_VALUE').IsNull) or (FieldByName('ITEM_VALUE').AsString='') then
SD[ppn]:='---'
else
SD[ppn]:=Dl(FieldByName('ITEM_VALUE').AsFloat)+'%';
end;
end;
except
on E: Exception do
Result := E.Message;
end;
end;
{判断数据库操作是否成功}
function Tledform.GetDB: string;
var
str:string;
begin
Result:='';
str:=DataModule1.GetSD(1,1);
if str<>'' then
{重新连接数据库,具体可根据自己的实际情况来处理!}
DataModule1.timer.enable:=true;
else
{正常连接数据库,无操作}
end;