none
Can you set a primary key on an empty datatable ? RRS feed

  • Question

  • Hi;

    I have created a datatable and I am adding data to it on the fly.

    I need to create a primary key on the table's first column before I add data to the table.

    Can you do this ?

    Or must the datatable contain data in the column that will be the primary key ?

    The reason I am asking is that all the examples I see create a PK on datatables alreaded filled with data ?

    Thanks for your Help !


    GeeMann
    Wednesday, July 6, 2011 3:26 PM

Answers

  • Hi GeeMann;

    Well the answer to that question would be if all the table columns are nullable except for the primary key then all that is needed is the primary key. Most table design require one or more columns to have a value in those cases the columns that are not nullable are required.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Marked as answer by GeeMann Wednesday, July 6, 2011 6:58 PM
    Wednesday, July 6, 2011 5:20 PM

All replies

  • Hi GeeMann;

    Well the answer to that question would be if all the table columns are nullable except for the primary key then all that is needed is the primary key. Most table design require one or more columns to have a value in those cases the columns that are not nullable are required.

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Marked as answer by GeeMann Wednesday, July 6, 2011 6:58 PM
    Wednesday, July 6, 2011 5:20 PM
  • Thanks
    GeeMann
    Wednesday, July 6, 2011 6:58 PM