简体   繁体   中英

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

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 programmatically 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM