ABSQuery1.SQL.Clear;
ABSQuery1.SQL.Add('
Insert into Sensors (Field,HWM_ID,Sensor_ID,Sensor_Class,Monitor_Name) values ( :Field, :hwm_id, :sensor_id,:sensor_class,:Monitor_Name );');
// Probably here prepare the Query!
// ABSQuery1.Prepared := True;
// fill SQL only once, the parameters will be filled in your for-struct
// where is the value for :Field? you must fill it!
for hwm_index := 0
to NBMonitors - 1
do begin
CPUIDSDK_GetHardwareMonitorName(hwm_index, ptrName);
// missing value for :Field... like following
// ABSQuery1.ParamByName('Field').AsInteger = 4711;
for sensor_index := 0
to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_VOLTAGE) - 1
do begin
ABSQuery1.ParamByName('
HWM_ID').AsString:=inttostr(hwm_index);
// better: ABSQuery1.ParamByName('HWM_ID').Asinteger:=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);
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;
ABSQuery1.ExecSQL;
// exec SQL after filling parameters
end;