Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Базы данных и репортинг > spCTPControlTITFieldByName('Znach').AsFloat


Автор: Grif13 18.1.2006, 16:32
Вытаскиваю из MS SQL данные через ADO.
Исползую хранимую процедуру
spCTPControlTITFieldByName('Znach').AsFloat

В базе лежит число 34,23 а в Делви приходит 34,2334653
Почему так происходит и что можно сделать?


Автор: sexton 18.1.2006, 17:14
Установи у объекта TField св-во Precision.
Цитата

__property int Precision = {read=FPrecision, write=SetPrecision, default=15};

Description

Use Precision to set the number of digits beyond the decimal point that the value should be formatted to before rounding begins. Precision affects the format of the floating-point value when it is displayed as a text string, not the actual floating-point value that is stored in the field.

The default value of Precision is 15 decimal places.

Note: Precision must be greater than or equal to 2. Trying to set Precision to a value less than 2 changes the value of Precision to 2.

Автор: Grif13 19.1.2006, 08:03
Цитата(sexton @ 18.1.2006, 17:14)
Установи у объекта TField св-во Precision.
Цитата

__property int Precision = {read=FPrecision, write=SetPrecision, default=15};



Я так и делаю. Если выводит это поле в dbGrid? то все нормально.
Но если присваивать значение поля (какой нибудь строки) переменной,
то добовляются еще какие то цифры.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)