Solved

C++ VS 6.0 ADO Access fields by number.

Posted on 2004-03-29
3
281 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

756 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