471,595 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Column does not belong to Table error

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

Jan 9 '07 #1
1 2420
in the Table.Columns collection to see if the column exists. you could
also add the column if missing.

-- bruce (sqlwork.com)

shil wrote:
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 <modenode 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.
Jan 10 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mkomasi | last post: by
7 posts views Thread by Patrick Olurotimi Ige | last post: by
5 posts views Thread by Kejpa | last post: by
10 posts views Thread by Nick | last post: by
reply views Thread by Mike | last post: by
4 posts views Thread by Mike | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.