http://msdn.microsoft.com/en-us/library/windows/desktop/ms675103(v=vs.85).aspx ADO defines several collections, including Fields, Parameters, Properties, and Errors. In Visual C++, the GetItem(index) method returns a member of the collection. Index is a Variant, the value of which is either a numeric index of the member in the collection, or a string containing the name of the member. The __declspec(property...) compiler directive declares the Item property as an alternative syntax to each collection's fundamental GetItem() method. The alternative syntax uses square brackets and looks similar to an array reference. In general, the two forms look like the following: collectionPtr->GetItem(index); collectionPtr->Item[index]; For example, assign a value to a field of a Recordset object, named rs, derived from the authors table of the pubs database. Use the Item() property to access the third Field of the Recordset object Fields collection (collections are indexed from zero; assume the third field is named au_fname). Then call the Value() method on the Field object to assign a string value.
ADO defines several collections, including Fields, Parameters, Properties, and Errors. In Visual C++, the GetItem(index) method returns a member of the collection. Index is a Variant, the value of which is either a numeric index of the member in the collection, or a string containing the name of the member.
The __declspec(property...) compiler directive declares the Item property as an alternative syntax to each collection's fundamental GetItem() method. The alternative syntax uses square brackets and looks similar to an array reference. In general, the two forms look like the following:
collectionPtr->GetItem(index);
collectionPtr->Item[index];
For example, assign a value to a field of a Recordset object, named rs, derived from the authors table of the pubs database. Use the Item() property to access the third Field of the Recordset object Fields collection (collections are indexed from zero; assume the third field is named au_fname). Then call the Value() method on the Field object to assign a string value.
CString CDatagrid1::GetItem(int ColNum)
{
CColumns cols = get_Columns();
VARIANT v_ColNum, v_Value;
//设置列编号
v_ColNum.vt = VT_I2;
v_ColNum.iVal = ColNum;
//根据列编号返回CColumn对象
CColumn col = cols.GetItem(v_ColNum);
//读取列的
v_Value = col.GetValue();
return _variant_t(v_Value.bstrVal);
}