Identiy Columns

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dhernando

    #1

    Identiy Columns

    Hi, I know how to get table columns with getoledbschemat able and how to get the columns and type for a specific table but i need to know if a column have a identity type (incremental) please how can i get this information

    ---
    Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
  • Miha Markic

    #2
    Re: Identiy Columns

    Hi,

    This is tricky, as it depends on provider:
    for sqlserver it seems that column_flags = 16 and data_type=3 indicates
    autonumbering
    while for oledb/jet4 it seems that column_flags=90 and data_type=3 indicates
    autonumbering

    --
    Miha Markic - RightHand .NET consulting & software development
    miha at rthand com

    "dhernando" <dhernando@-NOSPAM-itecperu.com> wrote in message
    news:eBS7gpSxDH A.3220@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi, I know how to get table columns with getoledbschemat able and how to[/color]
    get the columns and type for a specific table but i need to know if a column
    have a identity type (incremental) please how can i get this information[color=blue]
    >
    > ---
    > Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest[/color]
    Community Website: http://www.dotnetjunkies.com/newsgroups/


    Comment

    • Miha Markic

      #3
      Re: Identiy Columns

      Hi,

      This is tricky, as it depends on provider:
      for sqlserver it seems that column_flags = 16 and data_type=3 indicates
      autonumbering
      while for oledb/jet4 it seems that column_flags=90 and data_type=3 indicates
      autonumbering

      --
      Miha Markic - RightHand .NET consulting & software development
      miha at rthand com

      "dhernando" <dhernando@-NOSPAM-itecperu.com> wrote in message
      news:eBS7gpSxDH A.3220@tk2msftn gp13.phx.gbl...[color=blue]
      > Hi, I know how to get table columns with getoledbschemat able and how to[/color]
      get the columns and type for a specific table but i need to know if a column
      have a identity type (incremental) please how can i get this information[color=blue]
      >
      > ---
      > Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest[/color]
      Community Website: http://www.dotnetjunkies.com/newsgroups/


      Comment

      • Nice Chap

        #4
        Re: Identiy Columns

        There is another way but it is slower than what Miha has suggested.

        DataAdatper has a method called FillSchema. Call this method and then
        examine the DataColumn elements of the Table. DataColumn has Properties

        1. AutoIncrement 2) AutoIncrementSe ed 3) AutoIncrementSt ep


        Comment

        • dhernando

          #5
          re: Re: Identiy Columns

          Thank you for help me, look i have this procedure, look in the last case "isautoincremen t" looks ok but is not working everything else work fine please maybe you can see where is the error thanks a lot

          cmd.CommandText = "SELECT * FROM " + tblName
          cmd.Connection = cnn
          myReader = cmd.ExecuteRead er()
          schemaTable = myReader.GetSch emaTable()
          i=0
          foreach (DataRow myField in schemaTable.Row s

          foreach (DataColumn myProperty in schemaTable.Col umns)

          switch (myProperty.Col umnName.ToLower ())

          case "columnname "
          listView1.Items .Add (myField[myProperty].ToString())
          break
          case "columnsize "
          listView1.Items[i].SubItems.Add(m yField[myProperty].ToString())
          break
          case "datatype"
          listView1.Items[i].SubItems.Add(m yField[myProperty].ToString())
          break
          case "isautoincremen t"
          listView1.Items[i].SubItems.Add(m yField[myProperty].ToString())
          break


          i++
          }

          ---
          Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/

          Comment

          Working...