Autor Beitrag
wwwdirk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D6 Prof / D2005 Prof
BeitragVerfasst: Fr 27.04.07 11:25 
Hallo,

habe folgendes Problem:

Aufgrund verschiedener, komplexer DB-Abfragen benutze ich für den Datenzugriff oft das TADODataSet mit CommandType := cmdText und entsprechendem Selectstatement im CommandText.

Während der Laufzeit greife ich meine einzelnen Felder der Datenmenge über FieldByName ab, ohne Einträge im Feldeditor vorzunehmen.

Dadurch überlasse ich Delphi die Zuordnung des richtigen Datentyps. Funktioniert auch soweit. Enthält die Abfrage allerdings eine Berechnung (z.B. select a, b, a/b adurchb from test) dann, generiert Delphi bei der Auswertung mit FieldByName ('adurchb').AsFloat eine Feldkomponente vom Typ TBCDField (statt TFloatField), das hat Auswirkungen auf Genauigkeit und Rundungsverhalten.

Kann man diese Konvertierung unterdrücken oder umgehen, ohne alle Felder dem Feldeditor hinzuzufügen und manuell den Feldtyp zu setzen.

Vielen Dank u. viele Grüße
Dirk

P.S. ich hoffe meine Problem wird klar, hört sich irgendwie komplizierter an als es ist!
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Sa 28.04.07 12:02 
Setzt TADODataset.EnableBCD Property auf False.
EnableBCD steuert ob beim Erzeugen von TField Objekten bei Floats TBCDField oder TFloatField verwendet wird.

Gruß
wwwdirk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D6 Prof / D2005 Prof
BeitragVerfasst: Mo 30.04.07 06:09 
Genau danach hab ich gesucht! DANKE
Dirk
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mo 30.04.07 06:12 
Mich würde interessieren, wieso du Float ggü BCD vorziehst. Ich würde das umgekehrt machen, denn schließlich ist Float ungenau, und nicht BCD.

Na ja, beide sind ungenau, aber bei BCD ist 0.1 = 0.1 (im Gegensatz zu Float ;-) )

_________________
Na denn, dann. Bis dann, denn.
wwwdirk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D6 Prof / D2005 Prof
BeitragVerfasst: Di 10.07.07 13:47 
TBCDField beherrscht leider nur 4 Dezimalstellen und hat meine viel genaueren Werte (teilweise mit mehr als 10 Dezimalstellen) aus der Datenbank immer gerundet. Das war für mich in dem Fall nicht akzeptabel.