In order to have multiple column primary key, you must do:
0) suppose we have the table User, we want the two columns Name, LastName
to be the PK
table_shared_ptr user = db->add_table( ... );
1) add the fields that are part of the primary key and store de
fied_shared_ptr:
field_shared_ptr user_name = user->add_field("Name", ...);
field_shared_ptr last_name = user->add_field("Name", ...);
2) use set_primary_key method to specify the table PK. You can do that by
passing the names of the columns, the field pointer, etc...
field_container_type fields;
fields.push_back( user_name );
fields.push_back( last_name );
user->set_primary_key( fields );
That's it :)
At 09:04 18/03/2004 -0600, you wrote:
>The question(s) and comments below were transferred from support request.
>I am still using sqlpp and I have had few problems with the C++ Libs. I
>use the multi-column primary and foreign key methods extensively. In fact,
>I have generated flawless queries with multiple tables having multi-column
>PK and FK relationships. The problems outlined below began when I
>generated ASPX, C# code behind and C#. Regards, Randall Davis
>
>
>
>
>
>
>Previous JD comments:
>Hi, if you are still using sqlpp it would be nice to discuss
>such features in the mailing list. You can define multiple primary key
>without problem. I'll put an example on the wiki.
>R.D. Question:
>Summary: Primary Keys Initial Comment: I am using sqlpp to model and QBE
>using a meta data repository and I have had great success with a
>few exceptions(spacing around "AND" in joins). I make a few changes and
>it seems to work fine. I am now testing CS and aspnet generation. I am
>using release 2.9, XP pro and VS2003. I am new to C# and ASP.NET and the
>DNN approach to data access, but the problems I am having actually occur
>due the assumption that primary keys are generated ids or sequences. All
>of the pk's and fk's in my repository are multi-column
>and must be input by the user. The CS generator and aspnet generators
>(implicitly) assume that the pks are generated. Is there a way to get
>around this assumption? BTW, the control generator generates code to
>access text boxes that are not created for primary key columns. There
>is also a problem with this construct
>// m_RA_IDE_CHANGE_RULE_TBLDataGrid.OnItemCommand=
>"m_RA_IDE_CHANGE_RULE_TBLDataGrid_Click"; the method is not accessible due
>to protection level. Booleans should be initialized with true (currently
>"True"). This gives a string conversion error.
-----------------------------------------------------------------------------------
Jonathan de Halleux, Research Assistant
Center for Systems Engineering and Applied Mechanics (CESAME)
Universite catholique de Louvain
Batiment Euler , Av. Georges Lemaitre, 4 Tel : +32-10-47 2595
B-1348 Louvain-la-Neuve Belgium
E-mail : deh...@au...
-----------------------------------------------------------------------------------
|