|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
DataTable.PrimaryKey-Eigenschaft
Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
| Ausnahme | Bedingung |
|---|---|
| DataException |
private void GetPrimaryKeys(DataTable table) { // Create the array for the columns. DataColumn[] columns; columns = table.PrimaryKey; // Get the number of elements in the array. Console.WriteLine("Column Count: " + columns.Length); for(int i = 0; i < columns.Length; i++) { Console.WriteLine(columns[i].ColumnName + columns[i].DataType); } } private void SetPrimaryKeys() { // Create a new DataTable and set two DataColumn objects as primary keys. DataTable table = new DataTable(); DataColumn[] keys = new DataColumn[2]; DataColumn column; // Create column 1. column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName= "FirstName"; // Add the column to the DataTable.Columns collection. table.Columns.Add(column); // Add the column to the array. keys[0] = column; // Create column 2 and add it to the array. column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "LastName"; table.Columns.Add(column); // Add the column to the array. keys[1] = column; // Set the PrimaryKeys property to the array. table.PrimaryKey = keys; }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.