Home » Category » DotNet

DotNet: Identiy Columns

205| Wed, 21 May 2008 05:03:00 GMT| anonymous| Comments (3)
Hi, I know how to get table columns with getoledbschematable 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/

Keywords & Tags: identiy, columns, dotnet, .net

URL: http://dotnet.itags.org/dotnet-tech/317756/
 
«« Prev - Next »» 3 helpful answers below.
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:eBS7gpSxDHA.3220...tk2msftngp13.phx.gbl...
> Hi, I know how to get table columns with getoledbschematable 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 | Wed, 21 May 2008 05:04:00 GMT |

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) AutoIncrementSeed 3) AutoIncrementStep

nice | Wed, 21 May 2008 05:05:00 GMT |

Thank you for help me, look i have this procedure, look in the last case "isautoincrement" 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.ExecuteReader()
schemaTable = myReader.GetSchemaTable()
i=0
foreach (DataRow myField in schemaTable.Rows

foreach (DataColumn myProperty in schemaTable.Columns)

switch (myProperty.ColumnName.ToLower())

case "columnname"
listView1.Items.Add (myField[myProperty].ToString())
break
case "columnsize"
listView1.Items[i].SubItems.Add(myField[myProperty].ToString())
break
case "datatype"
listView1.Items[i].SubItems.Add(myField[myProperty].ToString())
break
case "isautoincrement"
listView1.Items[i].SubItems.Add(myField[myProperty].ToString())
break

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

dhernando | Wed, 21 May 2008 05:06:00 GMT |

DotNet Hot Answers

DotNet New questions

DotNet Related Categories