How to determine primary columns in a table
-
I am trying to determine primary key in a table wher Table is fetched from sql server database, but following code is not returning me Primary Key. private void GetPrimaryKeys(DataTable myTable) { DataColumn[] pkSource; pkSource = myTable.PrimaryKey; for (int i = 0; i < pkSource.Length; i++) { Console.Write(pkSource[0].ColumnName[i]); } }
Naveed Kamboh Complexity kills, Write easy code for your self. Cash-time
-
I am trying to determine primary key in a table wher Table is fetched from sql server database, but following code is not returning me Primary Key. private void GetPrimaryKeys(DataTable myTable) { DataColumn[] pkSource; pkSource = myTable.PrimaryKey; for (int i = 0; i < pkSource.Length; i++) { Console.Write(pkSource[0].ColumnName[i]); } }
Naveed Kamboh Complexity kills, Write easy code for your self. Cash-time
Make sure that you mytable contains information about the existing table fetched from sql server