我怎么知道十进制字段的精度和比例 [英] How can I know the precision and scale of a decimal field
问题描述
在VC ++中使用ACEDAO,我试图检索Access数据库(.accdb文件)表的字段详细信息,其中一个字段是十进制类型。我可以使用
Using ACEDAO in VC++, I am trying to retrieve the field details of an Access database (.accdb file) table of which one field is of decimal type. I am able to get the details using the functions of
DAO::_FieldPtr field;
的功能获取详细信息,如下所示:
as follows:
fieldName = field->GetName().GetBSTR();
nType = field->GetType() // returns DAO::dbDecimal
lSize = field->GetSize(); // returns 16
lAttr = field->GetAttributes(); // returns 0x000002H
nOrdinal = field->GetOrdinalPosition(); // returns 11
bAutoIncrement = ((lAttr & DAO::dbAutoIncrField) > 0);
DAO::PropertiesPtr props;
DAO::PropertyPtr prop;
int k, nProp;
std::wstring propName, propNames;
props = field->GetProperties();
if(props)
{
nProp = props->GetCount(); // returns 33
for(k = 0; k < nProp; k++)
{
prop = field->GetProperties()->GetItem((short) k);
if(prop)
{
propName = prop->GetName().GetBSTR();
propNames += propName;
propNames += L"\n";
}
}
// After exiting the loop, propNames contain 33 properties as:
// Value
// Attributes
// CollatingOrder
// Type
// Name
// OrdinalPosition
// Size
// SourceField
// SourceTable
// ValidateOnSet
// DataUpdatable
// ForeignName
// DefaultValue
// ValidationRule
// ValidationText
// Required
// AllowZeroLength
// AppendOnly
// Expression
// FieldSize
// OriginalValue
// VisibleValue
// GUID
// ColumnWidth
// ColumnOrder
// ColumnHidden
// Description
// DecimalPlaces
// DisplayControl
// TextAlign
// AggregateType
// ResultType
// CurrencyLCID
// But does not have any property named "Scale" or "Precision"
}
我找不到任何用于检索十进制字段的精度和比例值的函数。
虽然我能够将字段值检索为十进制数并从结构中获取所需信息,但我认为这不是正确的方法。因为,如果表中的字段数据不可用,会发生什么?
是否有其他方法可以使用其他方法来检索十进制类型字段的精度和比例ACEDAO?
谢谢。
I could not find any function for retrieving the value for precision and scale for the decimal field.
Though I am able to retrieve the field value as a decimal number and get the required information from the structure, I think it is not the right way. Because, what will happen if the data for field is not available in the table?
Is there any other method to retrieve the precision and scale of a decimal type field using ACEDAO?
Thanks.
推荐答案
不要使用DAO。
根据此链接,DAO不支持精确度。
http://allenbrowne.com/ser-49.html#_ftn7 [ ^ ]
请改用ADO。
Don't use DAO.
According to this link, DAO does not support precision.
http://allenbrowne.com/ser-49.html#_ftn7[^]
Use ADO instead.
这篇关于我怎么知道十进制字段的精度和比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!