Fixed Price Projects          Flexibele IT oplossingen

Software op maat              Web Applications

Using a datatable with primary key

 

Dim dt As New DataTable

dt.Columns.Add(New DataColumn("id", GetType(Integer)))

dt.PrimaryKey = New DataColumn() {dt.Columns("id")}

dt.Columns.Add(New DataColumn("name", GetType(String)))

dt.Columns.Add(New DataColumn("address", GetType(String)))

 

'check if there is a row where the primary key = ID = 1

If dtVerschillen.Rows.Contains(1) Then

… do stuff

End If

 

Best way to remove rows in datatable

'remove row with id=1 (if it exists)

If dtVerschillen.Rows.Contains(1) Then

dt.Rows.RemoveAt(dt.Rows.IndexOf(dt.Rows.Find(1)))

End If

Categorie: .NET
Actions: E-mail | Permalink |

waardering