Column does not belong to Table error

  • Thread starter Thread starter shil
  • Start date Start date
S

shil

Hi all,
From vb.net 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

<treatment_settings>
<setup>
<product1>
<name>PSO-NO2</name>
<mode>1</mode>
<setpoint>300.00</setpoint>
<range>12.00</range>
<density>10.6300</density>
<tr_pf>300.00</tr_pf>
<tp_pf>10.00</tp_pf>
</product1>
<product2>
<name />
<mode>0</mode>
<setpoint>80.00</setpoint>
<range>4.00</range>
<density>9.4300</density>
<tr_pf>300.00</tr_pf>
<tp_pf>10.00</tp_pf>
</product2>
</setup>
</treatment_settings>

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
Next
Next
____________________________________________________
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?

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

-- bruce (sqlwork.com)
 
Back
Top