Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to determine primary columns in a table

How to determine primary columns in a table

Scheduled Pinned Locked Moved C#
databasesql-servercomsysadminalgorithms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naveed Kamboh
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • N Naveed Kamboh

      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

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Make sure that you mytable contains information about the existing table fetched from sql server

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups