Solved

fields define from struct in vc++ 6.0

Posted on 2008-11-01
7
310 Views
Last Modified: 2012-05-05
hi,
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 ?
0
Comment
Question by:hp746
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

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

Open in new window

0
 
LVL 86

Expert Comment

by:jkr
ID: 22858511
Or, alternatively, you can set the members individually:
CAdoFieldInfo afi;
 

strcpy(afi.m_strName,"fieldname");

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

0
 

Author Comment

by:hp746
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;

};
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:jkr
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

0
 

Author Comment

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

Accepted Solution

by:
jkr earned 500 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")
0
 

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
  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 …
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 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

12 Experts available now in Live!

Get 1:1 Help Now