How to check if a column with a given name exists in a datarow

Dr. Rajesh Rolen picture Dr. Rajesh Rolen · Dec 31, 2009 · Viewed 33.4k times · Source

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).

Answer

Dr. Rajesh Rolen picture Dr. Rajesh Rolen · Dec 31, 2009

I got the answer.and its working . its:

  If dr.Table.Columns.Contains("columnname") = True Then
   --your work---
  End If