How to define a VB.NET DataTable Column as primary key after creation

前端 未结 5 649
天命终不由人
天命终不由人 2021-02-08 22:40

I am importing Tables from a Oracle DataBase, using a VB.NET dataAdapter. I use the \"fill\" command to add the imported data to a DataSet. How is it possible to define a specif

5条回答
  •  渐次进展
    2021-02-08 22:56

    Thanks for the answer Rob - there is a slight issue with the vb version though as the index should be zero-based:

    Dim table As New DataTable()
    
    table.Columns.Add(New DataColumn("MyColumn"))
    
    Dim primaryKey(1) As DataColumn
    primaryKey(0) = table.Columns("MyColumn")
    table.PrimaryKey = primaryKey
    

提交回复
热议问题