![]() |
Re: SQL problem
Sorry was a little typo which happens if you type faast! :)
But now no updated records :(
Delphi-Quellcode:
Item:=false;
end else begin ABSQuery1.SQL.Clear; ABSQuery1.SQL.Text := 'UPDATE Sensors SET Field="' +sField+'"' +','+'Value="'+sValue+'"'+','+'Min="'+sMin+'"'+','+'Max="'+sMax+'"'+' WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID'; 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; |
Re: SQL problem
What are :Sensor_Class, :HWM_ID, :Sensor_ID? Are these Delphi-Variables? Then you must quote and add them (if they are strings! otherwise you must convert them to string!)
Delphi-Quellcode:
And put brackets () around every logical statement!
'...WHERE (HWM_ID = '+:HWM_ID+') and (Sensor_Class = '+:Sensor_Class+') and (Sensor_ID ='+ :Sensor_ID+')';
edit: rubbish |
Re: SQL problem
I thought with parameters is good?
delphi variables are
Delphi-Quellcode:
var
sField,sMax,sMin,sValue:String; begin |
Re: SQL problem
Zitat:
Zitat:
|
Re: SQL problem
Oh :oops: my fault. Just overlooked the whole parameter thing... Then move on Mr ;-) I don't know, how to address the parameters here.
Ok, brackets arent necessary. Just a habit of me oO |
Re: SQL problem
Yes setting long SQL texts is trouble for most 3rd party databases..
|
Re: SQL problem
Ist just oen reason for parameters. But the main reasons are type-conversion, type formats (e.g. date values) and the performance boost of using prepared statements for mass import/updates etc.
|
Re: SQL problem
I don't understand why it won't update Records :wall:
Edit:
Delphi-Quellcode:
Edit1 reports this
Edit1.Text:=ABSQuery1.SQL.Text;
SQL-Code:
UPDATE Sensors SET Field="",Value="",Min="",Max="" WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID
|
Re: SQL problem
Is an error shown or just nothing happens?
|
Re: SQL problem
Does the code compile? Do you get any error messages or arent there just any updated records?
If it runs and there are just no records updated then set breakpoints and step through your code. Maybe one of the functions (CPUIDSDK_GetNumberOfSensors or CPUIDSDK_GetSensorInfos) returns a wrong value? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz