views:

656

answers:

3

i want to insert a value from loop in datarow so before entering value in datarow i want to check that a perticular column NAME exist in table or not...please tell me how can i check it.. (vb.net preferred).

A: 

Try this

Dim dt As New DataTable
For Each dc As DataColumn In dt.Columns
    If dc.ColumnName = "" Then

    End If
Next
Anuraj
A: 

I got the answer.and its working . its:

  If dr.Table.Columns.Contains("columnname") = True Then
   --your work---
  End If
Rajesh Rolen- DotNet Developer
A: 

A sample code to test if particular column exists in row will be:

Dim table As New DataTable()   
For Each row As DataRow In table.Rows
    If row.Table.Columns("name") IsNot Nothing Then
        'do something

    End If
Next
Adeel