Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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;

Independent Software Vendors: 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!

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 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.
Suggested Courses

580 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