删除数据表中的主键

xor*_*wer 10 c# asp.net datatable visual-studio

有没有办法从数据表中删除主键或有没有办法首先删除"PK"的约束,然后删除列本身?

谢谢!

更新:

 dtTable.Columns.Add(new System.Data.DataColumn("PRIMARY_KEY", typeof(System.Int32)));
 dtTable.PrimaryKey = new DataColumn[1] { dtTable.Columns["PRIMARY_KEY"] }; // throws an error
 dtTable.Columns["PRIMARY_KEY"].AutoIncrement = true;
Run Code Online (Sandbox Code Playgroud)

Pan*_*wal 19

您可以使用删除主要密钥

DataTable.PrimaryKey = null;
Run Code Online (Sandbox Code Playgroud)

您可以使用删除数据表列

DataTable.Columns.Remove("column name here");
Run Code Online (Sandbox Code Playgroud)