Column does not belong to Table error



Hi all,
From 2005, I'm reading a list of XML files into a dataset and
updating SQL database with the data.I'm stuck with an issue. One of the
XML file from the list don't have a node mentioned. For example almost
all XML files structure is like this

<name />

But few liles don't have <mode> node for product2. In that case I'm
getting Column does not belong to table error when I'm executing the
below code. I'm trying to save values into arrays and later in the code
I'm updating the database.
objDSXML.ReadXml(strWorkPath & "\TreatmentSettings.xml")
j = 0
For i = 1 to 2
For Each objDataRow In objDSXML.Tables(i).Rows
ControlMethod(j) = objDataRow("mode")
ProductName(j) = Trim(objDataRow("name"))
j = j + 1
I have tried using this code to see if the node exist.

If Not IsDBNull(objDataRow("mode")) Then
ControlMethod(j) = objDataRow("mode")
End If

Above code didn't work eiter.
Can any one tell me how to check if a node in the table exist?


bruce barker

in the Table.Columns collection to see if the column exists. you could
also add the column if missing.

-- bruce (

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