DataSet.Tables.IndexOf()

S

shil

Hi all,

I'm reading an XML file in to a DataSet object. Then trying to read
data from the XML file in to the database. I need to find if a
particular XML node exist in the file or not. For this I have the code
as below in VB.NET.

Dim objDSXML As New DataSet
Dim objDataRow

objDSXML.ReadXml("\Sample.xml")
If File.Exists("\Sample.xml") Then
For Each objDataRow In objDSXML.Tables(0).Rows
If objDSXML.Tables.IndexOf("Email") > -1 Then
Email = objDataRow("Email")
Else
Email = ""
End If
Next
End If

In my XML file even though the node <Email> exist, the If condition is
always returning -1. Is there some thing I'm missing here?
 
C

Cor Ligthert[MVP]

As there one row with a field exist in your xml file, then it exist in your
DataTable.
Therefore you can test if a datatable columns columname exist.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top