Meet a problem to ask everyone:
I want to get a ifeatrue of the nth column of data that I get in the following way:
VARIANT varvaltest;
Ipfeature->get_value (index,&varvaltest); where index is int type value
But the return of VARVALTEST.VT is vt_empty.
I use the following method (the function name does not proofread):
VARIANT varvaltest;
Ipfeature->gettable (&iptable);
Long loid=0;
Ipfeatrue->getloid (&loid);
Irowptr Iprow;
Iptable->getrow (Loid,&iprow);
Iprow->getvalue (index,&varvaltest);
You can return the correct value.
Ask the first way is not a problem, the problem is not with the value of the relationship, how to solve this problem. Because the second method affects efficiency at large amounts of data, it is best to solve them in the first way.
Thank you...
==========================================
Tested with VC, no problem.
LONG index=2;
Ifeatureptr pfeature;
Pfeatureclass->getfeature (index,&pfeature);
VARIANT var;
index=5;
Pfeature->get_value (Index,&var);
code to read ifeature field information
Ienvelopeptr ipenv (M_mapcontrol.trackrectangle ()); Iselectionenvironmentptr ipseletionenv (clsid_selectionenvironment); Ipseletionenv->put_searchtolerance (2); Ipseletionenv->put_combinationmethod (esriselectionresultnew); M_ipmap->selectbyshape (Ipenv,ipseletionenv,false); Iactiveview->partialrefresh (Esriviewgeoselection,null,null); Iselectionptr ipselection; M_ipmap->get_featureselection (&ipselection); Long Selcount; M_ipmap->get_selectioncount (&selcount);//Get the number of selection elements Ienumfeatureptr ipenumfeature (ipselection); Ipenumfeature->reset (); Ifeatureptr ipfeature; Ipenumfeature->next (&ipfeature); while (!) ( ipfeature==0)) { BSTR LayerName; Iobjectclassptr Pobjectclass; Ipfeature->get_class (&pobjectclass); Pobjectclass->get_aliasname (&layername)//Get the object name of the element CString Rootname=layername; Ifieldsptr Pfields; Ifieldptr Pfield; Long index;//Field Index Ipfeature->get_fields (&pfields); Const CString fieldname= "Misname";//define field name to query Pfields->findfield (_bstr_t (fieldname), &index); Get the specific field information CComVariant varvaltest; Ipfeature->get_value (index,&varvaltest); , and why the value is always empty. CString Fieldvalue; Fieldvalue=varvaltest.bstrval; Ipenumfeature->next (&ipfeature); } But this can get information, the speed is a bit slow ah, can be used to solve the previous method ah. Ipfeature->get_class (&pobjectclass); Pobjectclass->get_aliasname (&layername)//Get the object name of the element Ipfeature->get_oid (&loid); Re-Ifeatureclas get this element because Ipfeature doesn't return all the fields He only returned the ID Ipfeatureclass=pobjectclass; Itableptr ptable; Irowptr prow; Ptable=ipfeatureclass; Ptable->getrow (Loid,&prow); Prow->get_value (index,&varvaltest); |