Solved

C++ VS 6.0 ADO Access fields by number.

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now