Solved

fields define from struct in vc++ 6.0

Posted on 2008-11-01
7
307 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  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 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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

759 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

19 Experts available now in Live!

Get 1:1 Help Now