开发者

How to get the default value of a column of MS Access Database using C++?

开发者 https://www.devze.com 2022-12-09 14:36 出处:网络
This is the sql script I used to create a table in MS Access Database. CREATE TABLE Contracts ( id intNULL DEFAULT 0,

This is the sql script I used to create a table in MS Access Database.

CREATE TABLE Contracts (
id int  NULL DEFAULT 0,
sex varchar(255) DEFAULT 'female' NOT NULL
)

Now I want to progr开发者_运维百科ammatically get the default value of the field: "sex", I know it's 'female' but I don't know how to get it using C++ ADO interface.

Below is a snippet of my code:

m_pRecordset->Fields->get_Item(vIntegerType, &pvObject);
bstrColName = pvObject->GetName();
dtype = pvObject->GetType();
attr = pvObject->GetAttributes();


I can give you idea how to achieve it..

GetAttributes() method will not give you default value of the field but it will give you info about whether field is autoincrement ,system field or fixed - variable size field.

Check out for method GetDefaultValue() of the field that will do what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消