AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

SQL problem

Ein Thema von nanix · begonnen am 7. Dez 2009 · letzter Beitrag vom 8. Dez 2009
Antwort Antwort
Seite 3 von 4     123 4      
nanix
(Gast)

n/a Beiträge
 
#21

Re: SQL problem

  Alt 7. Dez 2009, 14:10
No code compiles runs OK no errors.But ofcourse all functions work becouse previously some same functions are used to INSERT records

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;
ABSQuery1.ExecSQL;
I am speculating the SQL text...
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#22

Re: SQL problem

  Alt 7. Dez 2009, 14:19
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:
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';
Markus Kinzler
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#23

Re: SQL problem

  Alt 7. Dez 2009, 14:28
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;
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#24

Re: SQL problem

  Alt 7. Dez 2009, 14:32
Try parameters
Markus Kinzler
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#25

Re: SQL problem

  Alt 7. Dez 2009, 14:35
Zitat von nanix:
I don't understand why it won't update Records

Edit:
Edit1.Text:=ABSQuery1.SQL.Text; Edit1 reports this

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)?
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#26

Re: SQL problem

  Alt 7. Dez 2009, 14:38
No i get this in edit1

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
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#27

Re: SQL problem

  Alt 7. Dez 2009, 14:46
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
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#28

Re: SQL problem

  Alt 7. Dez 2009, 14:49
I uploaded unit and db file i use its ABSOLUTE DATABASE.
Angehängte Dateien
Dateityp: rar demos_276.rar (2,5 KB, 3x aufgerufen)
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#29

Re: SQL problem

  Alt 7. Dez 2009, 14:58
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?
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#30

Re: SQL problem

  Alt 7. Dez 2009, 15:01
Its like any other DB..

http://www.componentace.com/download...hp?editionid=1
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 4     123 4      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz