assigning primary key to more than one column

Discussion in 'Microsoft VB .NET' started by gaffar, Jan 6, 2005.

  1. gaffar

    gaffar Guest

    Sir,

    if we want to assign a primary key to a single cloumn. below code is used.

    objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
    "PrimaryKey_Field")

    if i want to assign primary to more than one column then what will be code.
     
    gaffar, Jan 6, 2005
    #1
    1. Advertisements

  2. Hi,

    The datatable's primarykey accepts an array of datacolumns. Link
    shows an example.

    http://msdn.microsoft.com/library/d...rfsystemdatadatatableclassprimarykeytopic.asp

    Ken
    ------------------------
    "gaffar" <> wrote in message
    news:eX91wD%...
    Sir,

    if we want to assign a primary key to a single cloumn. below code is used.

    objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
    "PrimaryKey_Field")

    if i want to assign primary to more than one column then what will be code.
     
    Ken Tucker [MVP], Jan 6, 2005
    #2
  3. gaffar

    gaffar Guest

    Sir Can you help the same code in the Vb.net
    "Ken Tucker [MVP]" <> wrote in message
    news:u66cTg#...
    > Hi,
    >
    > The datatable's primarykey accepts an array of datacolumns. Link
    > shows an example.
    >
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
    frlrfsystemdatadatatableclassprimarykeytopic.asp
    >
    > Ken
    > ------------------------
    > "gaffar" <> wrote in message
    > news:eX91wD%...
    > Sir,
    >
    > if we want to assign a primary key to a single cloumn. below code is

    used.
    >
    > objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
    > "PrimaryKey_Field")
    >
    > if i want to assign primary to more than one column then what will be

    code.
    >
    >
    >
     
    gaffar, Jan 7, 2005
    #3
  4. Hi,

    Try something like this.
    dsClient.Tables(0).PrimaryKey = New DataColumn()
    {dsClient.Tables(0).Columns("FirstName"),
    dsClient.Tables(0).Columns("LastName")}



    Ken

    ---------------------------

    "gaffar" <> wrote in message
    news:%...
    Sir Can you help the same code in the Vb.net
    "Ken Tucker [MVP]" <> wrote in message
    news:u66cTg#...
    > Hi,
    >
    > The datatable's primarykey accepts an array of datacolumns. Link
    > shows an example.
    >
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
    frlrfsystemdatadatatableclassprimarykeytopic.asp
    >
    > Ken
    > ------------------------
    > "gaffar" <> wrote in message
    > news:eX91wD%...
    > Sir,
    >
    > if we want to assign a primary key to a single cloumn. below code is

    used.
    >
    > objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary,
    > "PrimaryKey_Field")
    >
    > if i want to assign primary to more than one column then what will be

    code.
    >
    >
    >
     
    Ken Tucker [MVP], Jan 7, 2005
    #4

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    2,288
    Guest
    Dec 3, 2003
  2. HAN(removethis)twister

    Any way to make DataView to filter for more than one column?

    HAN(removethis)twister, Feb 8, 2004, in forum: Microsoft VB .NET
    Replies:
    4
    Views:
    576
    Dominique Vandensteen
    Feb 8, 2004
  3. gaffar

    how to assign primary key to more than one field

    gaffar, Jan 10, 2005, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    169
    Cor Ligthert
    Jan 10, 2005
  4. Thief_

    More than one column in a Combobox?

    Thief_, Aug 23, 2005, in forum: Microsoft VB .NET
    Replies:
    5
    Views:
    198
    Thief_
    Aug 23, 2005
  5. Mike TI

    Can you have more than one column in Combo Box

    Mike TI, Mar 26, 2006, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    211
    Cor Ligthert [MVP]
    Mar 26, 2006
Loading...

Share This Page