fields define from struct in vc++ 6.0

Posted on 2008-11-01
Medium Priority
Last Modified: 2012-05-05
I have struct like this
struct CAdoFieldInfo
      // The name of field
      char m_strName[30];
      // the field type
      short m_nType;
      // The field size
      long m_lSize;
            // the attributes of field
      long m_lAttributes;
      // the ordinal position of current field
      short m_nOrdinalPosition;
      BOOL m_bRequired;  
      BOOL m_bAllowZeroLength;
      long m_lCollatingOrder;  

I want to define my fields like this

{ 'fieldname',adchar,20,YESNO    }

how would i achive like this ?
Question by:hp746
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
  • 4
  • 3
LVL 86

Expert Comment

ID: 22858498
You could do that like
CAdoFieldInfo afi = { "fieldname",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder};

Open in new window

LVL 86

Expert Comment

ID: 22858511
Or, alternatively, you can set the members individually:
CAdoFieldInfo afi;
afi.m_nType = addchar;
afi.m_lSize = 20;
afi.m_lAttributes = YESNO;
afi.m_nOrdinalPosition = 42;
afi.m_bRequired = TRUE;
afi.m_bAllowZero = TRUE;
afi.m_lCollatingOrder = MyOrder;

Open in new window


Author Comment

ID: 22858560
CAdoFieldInfo afi = { "fieldname",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder};
is afi holds only one fieldname or set of fields?
like i have 3 coulms in my table fname,lastname,stdno can i do like this
CAdoFieldInfo afi = { "fieldname",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder;
                                 "fieldname2",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder;
                                 "fieldname3",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder;

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 86

Expert Comment

ID: 22858776
Fot the latter one, you need an array of structs, e.g.
CAdoFieldInfo afi[3] = 
  { "fieldname",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder},
  { "fieldname2",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder},
  { "fieldname3",adchar,20,YESNO, 42, TRUE, TRUE, MyOrder}

Open in new window


Author Comment

ID: 22858808
once i have my fileds can i use BEGIN_ADO_BINDING(Class)
to bind .could you please let meknow how could i do this.since i am new to vc++ 6.0
LVL 86

Accepted Solution

jkr earned 2000 total points
ID: 22858842
Hm, I am afraid I won't be able to clarify that in a single comment. Check out these articles, both come with full source code:

http://www.codeproject.com/KB/database/adoclasses.aspx ("
ADO MFC Wrapper classes")
http://www.codeproject.com/KB/cpp/ADO_DB.aspx ("Updating and Adding Database Records Through ADO")

Author Comment

ID: 22858886
thank you very much for your help have a good week end

Featured Post

Industry Leaders: 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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.
Suggested Courses

770 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