Ask Ifeatrue Read information questions

Source: Internet
Author: User
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.