?
Solved

C++ VS 6.0 ADO Access fields by number.

Posted on 2004-03-29
3
Medium Priority
?
293 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 1500 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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

752 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