Delphi-PRAXiS
Seite 3 von 4     123 4      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi SQL problem (https://www.delphipraxis.net/144409-sql-problem.html)

nanix 7. Dez 2009 15:10

Re: SQL problem
 
No code compiles runs OK no errors.But ofcourse all functions work becouse previously some same functions are used to INSERT records :oops:

1.Set all parameters;

Delphi-Quellcode:
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);
2.Then populate the variables;
Delphi-Quellcode:
sField:=pansichar(ptrname);
sValue:=Format('%.3f V', [Value]);
sMin:=Format('%.3f V', [Min]);
sMax:=Format('%.3f V', [Max]);
3.Execute SQL script;
Delphi-Quellcode:
ABSQuery1.ExecSQL;

I am speculating the SQL text... :|

mkinzler 7. Dez 2009 15:19

Re: SQL problem
 
Conversion is not needed
Delphi-Quellcode:
ABSQuery1.ParamByName('HWM_ID').Value := hwm_index);
ABSQuery1.ParamByName('Sensor_Class').Value := SENSOR_CLASS_VOLTAGE;
ABSQuery1.ParamByName('Sensor_ID').Value := sensor_index;
You could use here parameters too:
SQL-Code:
UPDATE Sensors SET Field = :field ,value = :Value, Min = :min, Max = :max WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID';

nanix 7. Dez 2009 15:28

Re: SQL problem
 
I tryed executing after and it makes no diffrence :(

Delphi-Quellcode:
for hwm_index := 0 to NBMonitors - 1 do begin

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.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';
ABSQuery1.ExecSQL;
Edit1.Text:=ABSQuery1.SQL.Text;



end;
end;
end;
end;

mkinzler 7. Dez 2009 15:32

Re: SQL problem
 
Try parameters

ToFaceTeKilla 7. Dez 2009 15:35

Re: SQL problem
 
Zitat:

Zitat von nanix
I don't understand why it won't update Records :wall:

Edit:
Delphi-Quellcode:
Edit1.Text:=ABSQuery1.SQL.Text;
Edit1 reports this

SQL-Code:
UPDATE Sensors SET Field="",Value="",Min="",Max="" WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID

Do you still get these empty strings? Looks like the Values ([Value],[Min],[Max]) are empty or Format can`t convert them?!
Maybe the parameter '%.3f' breaks the function (doen't know, never worked with Format)?

nanix 7. Dez 2009 15:38

Re: SQL problem
 
No i get this in edit1

SQL-Code:
UPDATE Sensors SET Field="VIN3",Value="1.536 V",Min="1.536 V",Max="1.536 V" WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID
and it says this even tho its on timer 1 s interval :x

ToFaceTeKilla 7. Dez 2009 15:46

Re: SQL problem
 
Ok then i would guess its a database issue. What are the values of the parameters (:HWM_ID,...)? Are there database entries which match these? Because no match with "WHERE" - no update ;-)

nanix 7. Dez 2009 15:49

Re: SQL problem
 
Liste der Anhänge anzeigen (Anzahl: 1)
I uploaded unit and db file i use its ABSOLUTE DATABASE.

ToFaceTeKilla 7. Dez 2009 15:58

Re: SQL problem
 
Sorry, but I don't know Absolute DB and how to use it. Can't you just lookup if your DB contains entries which match the parameters? Maybe you have something like a management tool for this kind of DB?

nanix 7. Dez 2009 16:01

Re: SQL problem
 
Its like any other DB..

http://www.componentace.com/download...hp?editionid=1


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:17 Uhr.
Seite 3 von 4     123 4      

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