Solved

fields define from struct in vc++ 6.0

Posted on 2008-11-01
7
313 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
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

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

Technology Partners: 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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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.

749 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