none
how to get in DataRow on a Datatable composed of 3 primary keys

    Question

  • hi! pls answer following question about ado.net ...

    how to get in a DataRow on a Datatable (composed of 3 primary keys) using One primary key?
    or, we cannnot get it without using 3 keys?

    VS 2010

     

    Saturday, March 12, 2011 11:51 PM

Answers

  • Hello yasheeki,

     

    Welcome to the MSDN Forum and thanks for posting here.

    As I know, the primary key of a table must be unique to identify the record in the table. It's also possible to have a table with a primary key made up of two or more columns. This occurs when a single column can't contain enough unique values. For example, a two column primary key might consist of a "FirstName" and "LastName" column.

    Because primary keys can be made up of more than one column, the PrimaryKey property consists of an array of DataColumn objects.I think you can use the DataRowCollection.Find Method to find these keys.

    Here is a thread about how to use it:

    http://bytes.com/topic/visual-basic-net/answers/388471-using-find-method-primary-keys

    I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by yasheeki Wednesday, March 16, 2011 8:12 PM
    Monday, March 14, 2011 9:18 AM

All replies

  • Hello yasheeki,

     

    Welcome to the MSDN Forum and thanks for posting here.

    As I know, the primary key of a table must be unique to identify the record in the table. It's also possible to have a table with a primary key made up of two or more columns. This occurs when a single column can't contain enough unique values. For example, a two column primary key might consist of a "FirstName" and "LastName" column.

    Because primary keys can be made up of more than one column, the PrimaryKey property consists of an array of DataColumn objects.I think you can use the DataRowCollection.Find Method to find these keys.

    Here is a thread about how to use it:

    http://bytes.com/topic/visual-basic-net/answers/388471-using-find-method-primary-keys

    I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by yasheeki Wednesday, March 16, 2011 8:12 PM
    Monday, March 14, 2011 9:18 AM
  • thanks for your answer!

    i've received that the primary key of a table must be unique to identify the record in the table.
    so if only one key, i can't get it.

    i need a little more study about ado.net.

    i'm glad to hear your kind advice!

    Wednesday, March 16, 2011 1:28 PM