I have a DataSet in my MainForm and work as follows:
- Open the MainForm.Designer.cs in design mode and click on the dataset.
- Click in the properties window on data > tables > list to get the table editor.
- Click in the editor on the first table "wiki" and on the properties data > constraints > list.
- The constraints editor shows the member "Constraint1". Click on Edit.
- Change the name to "wikiPK" and activate the column "id" as well as "Primary Key". Save the changes by "OK".
- Close the constraints editor. Close the tables editor.
Go to the source code that shows the requested properties:
this.wikiTable.Constraints.AddRange(new System.Data.Constraint[ {
new System.Data.UniqueConstraint("wikiPK", new string[ {"id"}, true)});
this.wikiTable.PrimaryKey = new System.Data.DataColumn[ {this.wikiId};
Repeat the first 3 steps above and - oops: the constraint is renamed to "Constraint1". Moreover: Add a button with a click event to WriteXmlSchema(filename). The xml file contains the different values "Constraint1" like the following;
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//wiki" />
<xs:field xpath="id" />
</xs:unique>
<xs:unique name="user_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//user" />
<xs:field xpath="id" />
</xs:unique>
How can I set my own constraint names? Juergen
SharpDevelop Version : 5.0.0.4755-c848dc28
.NET Version : 4.5.50938
OS Version : Microsoft Windows NT 6.1.7601 Service Pack 1 (i.e. Win7 Home Premium)
Current culture : German (Germany) (de-DE)
Running under WOW6432, processor architecture: x86-64
PS. How can I display C# code? Neither [ code ] nor < code > (without spaces) works. The help link above leads to http://communityserver.org/r.ashx?K that links to http://community.zimbra.com/r automatically - oops, a blank screen only.