Solved

C++ VS 6.0 ADO Access fields by number.

Posted on 2004-03-29
3
284 Views
Last Modified: 2010-04-01
I figured out how to access columns in a row by using "_bstr_t xBar2 = (_bstr_t) m_Recordset->Fields->GetItem("xbar_2")->Value;".

Can someone please tell me how to access the columns by using a column# instead of name?
0
Comment
Question by:mmouer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
shalmak earned 500 total points
ID: 10707240
I believe its simply:

_bstr_t xBar2 = (_bstr_t) m_Recordset->Fields->GetItem(1)->Value;

that is, provide a number instead of a string to GetItem.

Quoting from the msdn:

In Visual C++, the GetItem(index) method returns a member of the collection. Index is a Variant, the value of which is either a numerical index of the member in the collection, or a string containing the name of the member.

hope this helps
Shalmak
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10707261
GetItem(colIndex) should work right?

Plz refer to code at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdprotypexvc.asp

-Lakshman
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 10707281
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question