Hi,
I want to determine column names of Primary Key Columns of a SQL Server
Table. To do this I've found following example in MSDN under PrimaryKey
property of DataTable. I've add some lines of code to initialize table
object and rest is as it
dim table as new datatable()
dim adp as new sqlclient.sqlda taadapter("Sele ct * from emp",cn)
adp.fill (table)
Dim columns() As DataColumn
columns = table.PrimaryKe y
' Get the number of elements in the array.
Console.WriteLi ne("Column Count: " & columns.Length. ToString())
Dim i As Integer
For i = 0 To columns.GetUppe rBound(0)
Console.WriteLi ne(columns(i).C olumnName &
columns(i).Data Type.ToString() )
Next i
according to msdn columns() arrary should contains primarykey column
information of emp table. But the above program not return any column
information.
so, How can we determine the column name of PrimaryKey of a sql server
table.?
Indar Bisen
I want to determine column names of Primary Key Columns of a SQL Server
Table. To do this I've found following example in MSDN under PrimaryKey
property of DataTable. I've add some lines of code to initialize table
object and rest is as it
dim table as new datatable()
dim adp as new sqlclient.sqlda taadapter("Sele ct * from emp",cn)
adp.fill (table)
Dim columns() As DataColumn
columns = table.PrimaryKe y
' Get the number of elements in the array.
Console.WriteLi ne("Column Count: " & columns.Length. ToString())
Dim i As Integer
For i = 0 To columns.GetUppe rBound(0)
Console.WriteLi ne(columns(i).C olumnName &
columns(i).Data Type.ToString() )
Next i
according to msdn columns() arrary should contains primarykey column
information of emp table. But the above program not return any column
information.
so, How can we determine the column name of PrimaryKey of a sql server
table.?
Indar Bisen