Thema: Delphi SQL problem

Einzelnen Beitrag anzeigen

nanix
(Gast)

n/a Beiträge
 
#4

Re: SQL problem

  Alt 7. Dez 2009, 13:59
Thanks 2 all , i thought everytime i need to execute SQL

But now if i want to update SQL i do it like this


Delphi-Quellcode:
procedure TForm3.Timer1Timer(Sender: TObject);
var
Value,Max,Min : single;
sensor_index,hwm_index,cpu_index,core_index,iValue,nbsensors,nbmonitors,
currOffset,lastOffset:integer;
szName : array[0..512] of Char;
ptrName : PChar;
sField,sMax,sMin,sValue:String;
begin
 ptrname:=szname;
 NbMonitors := CPUIDSDK_GetNumberOfHardwareMonitors();

if Item then begin


for hwm_index := 0 to NBMonitors - 1 do begin
CPUIDSDK_GetHardwareMonitorName(hwm_index, ptrName);
ABSQuery1.SQL.Clear;
ABSQuery1.SQL.Add('Insert into Sensors (HWM_ID,Sensor_ID,Sensor_Class,Monitor_Name) values ( :hwm_id, :sensor_id,:sensor_class,:Monitor_Name );');


for sensor_index := 0 to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_VOLTAGE) - 1 do begin
ABSQuery1.ParamByName('HWM_ID').AsString:=inttostr(hwm_index);
ABSQuery1.ParamByName('Monitor_Name').AsString:=pansichar(ptrname);
ABSQuery1.ParamByName('Sensor_ID').AsString:=inttostr(sensor_index);
ABSQuery1.ParamByName('Sensor_Class').AsString:=inttostr(SENSOR_CLASS_VOLTAGE);
ABSQuery1.ExecSQL;
end;

for sensor_index := 0 to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_TEMPERATURE) - 1 do begin
ABSQuery1.ParamByName('HWM_ID').AsString:=inttostr(hwm_index);
ABSQuery1.ParamByName('Monitor_Name').AsString:=pansichar(ptrname);
ABSQuery1.ParamByName('Sensor_ID').AsString:=inttostr(sensor_index);
ABSQuery1.ParamByName('Sensor_Class').AsString:=inttostr(SENSOR_CLASS_TEMPERATURE);

end;

for sensor_index := 0 to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_FAN) - 1 do begin
ABSQuery1.ParamByName('HWM_ID').AsString:=inttostr(hwm_index);
ABSQuery1.ParamByName('Monitor_Name').AsString:=pansichar(ptrname);
ABSQuery1.ParamByName('Sensor_ID').AsString:=inttostr(sensor_index);
ABSQuery1.ParamByName('Sensor_Class').AsString:=inttostr(SENSOR_CLASS_FAN);

end;
end;//end of loop

ABSQuery1.ExecSQL;
Item:=false;
end
else begin
ABSQuery1.SQL.Add('UPDATE Sensors SET Field="'   +sField+'"'     +','+'Value="'+sValue+'"'+','  +','+'Min="'+sMin+'"'+','  +','+'Max="'+sMax+'"'+',''WHERE (:HWM_ID,:Sensor_Class,:Sensor_ID);');
ABSQuery1.SQL.Clear;


for hwm_index := 0 to NBMonitors - 1 do

for sensor_index := 0 to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_VOLTAGE) - 1 do begin
if CPUIDSDK_GetSensorInfos(hwm_index,
sensor_index,
SENSOR_CLASS_VOLTAGE,
ptrName,
iValue,
Value,
Min,
Max)
then begin
ABSQuery1.ParamByName('HWM_ID').AsString:=inttostr(hwm_index);
ABSQuery1.ParamByName('Sensor_Class').AsString:=inttostr(SENSOR_CLASS_VOLTAGE);
ABSQuery1.ParamByName('Sensor_ID').AsString:=inttostr(sensor_index);

sField:=pansichar(ptrname);
sValue:=Format('%.3f V', [Value]);
sMin:=Format('%.3f V', [Min]);
sMax:=Format('%.3f V', [Max]);

ABSQuery1.ExecSQL;


end;
end;
end;






end;//End of loop
  Mit Zitat antworten Zitat