By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

Missing Row in DataSet

P: n/a
Still working on my XML DataSet...

Having moved on past difficult and complex problems, resolved with the
assistance of everyone here, I find myself facing yet another problem. My
XML document breaks the schema. There are missing tags everywhere, on
purpose I'm told, because we don't need them.

I'm getting a "System.Data: There is no row at position <row number>" error.
Hopefully I can workaround this issue. I need to find a way to keep going
past the missing row on to the next one, without throwing an exception.

Any suggestions?

--
Regards,

Fred Chateau
http://hotelmotelnow.com
May 25 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Your XML document breaks *what* schema? "There are missing tags everywhere"..
*what* missing tags are we talking about here?

If you are getting a "There is no row at position <row number>" error, it
may likely be because there aren't any rows at all, so looking for a
workaround to "get the next row" may be futile.

Suggest you practice a bit on how to make clearer posts so readers can be
more help.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Fred Chateau" wrote:
Still working on my XML DataSet...

Having moved on past difficult and complex problems, resolved with the
assistance of everyone here, I find myself facing yet another problem. My
XML document breaks the schema. There are missing tags everywhere, on
purpose I'm told, because we don't need them.

I'm getting a "System.Data: There is no row at position <row number>" error.
Hopefully I can workaround this issue. I need to find a way to keep going
past the missing row on to the next one, without throwing an exception.

Any suggestions?

--
Regards,

Fred Chateau
http://hotelmotelnow.com
May 25 '07 #2

P: n/a
Peter,

You are certainly correct. I was responding emotionally to the fact that
after spending a week developing a simple tool to transfer XML data to a
relational database, I finally got the tool working only to discover the XML
was bad. So, the tool is correctly reacting to the fact that the node it has
been instructed to find is not missing, but rather ambiguous.

I don't want to get too far off-topic, but a brief discussion of XML is in
order. An XML schema allows you to declare a node as optional, however not
all nodes can be optional. Is it one thing to declare a node at the top of a
hierarchy as optional. In that case, ADO responds by returning a DBNull for
the missing node. However, if a node that is within a certain hierarchy in
the document is declared as optional and is missing, it can no longer be
determined where the nodes above that node fit into the hierarchy. In that
case, ADO responds by returning the error : There is no record at position
<record numberor at least, that is what I believe is happening. It is
simply another way of saying that the node does not validate.

For example, take the most extreme case, of declaring a root node as
optional. If the root node is missing in the document, there basically is no
document to read. A good schema tool should not allow certain nodes to be
declared as optional, but if the schema is being written by hand, that case
can exist.

So, to return to the problem that I currently face is that I have an XML
document with 50,000 records, and a few of them are missing tags in
inappropriate places. ADO insists on dumping out of the loop when it gets to
an invalid node, so I'm stuck. I need to find a way to test for an invalid
node (missing record) and ignore it, or ignore the exception and continue on
to the next record.

I'm going to try simply removing the Using statement surrounding the loop
and see what happens. If that doesn't work, I need help.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:7C**********************************@microsof t.com...
Your XML document breaks *what* schema? "There are missing tags
everywhere"..
*what* missing tags are we talking about here?

If you are getting a "There is no row at position <row number>" error, it
may likely be because there aren't any rows at all, so looking for a
workaround to "get the next row" may be futile.

Suggest you practice a bit on how to make clearer posts so readers can be
more help.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Fred Chateau" wrote:
>Still working on my XML DataSet...

Having moved on past difficult and complex problems, resolved with the
assistance of everyone here, I find myself facing yet another problem. My
XML document breaks the schema. There are missing tags everywhere, on
purpose I'm told, because we don't need them.

I'm getting a "System.Data: There is no row at position <row number>"
error.
Hopefully I can workaround this issue. I need to find a way to keep going
past the missing row on to the next one, without throwing an exception.

Any suggestions?

--
Regards,

Fred Chateau
http://hotelmotelnow.com

May 26 '07 #3

P: n/a
Well, removing the Using statement didn't help so I think my next option is
to try an XmlTextReader, which brings up the question, do you need a
Try/Catch or Using statements surrounding an XmlTextReader?

--
Regards,

Fred Chateau
http://hotelmotelnow.com
"Fred Chateau" <we*******@hotelmotelnow.comwrote in message
news:el**************@TK2MSFTNGP06.phx.gbl...
Peter,

You are certainly correct. I was responding emotionally to the fact that
after spending a week developing a simple tool to transfer XML data to a
relational database, I finally got the tool working only to discover the
XML was bad. So, the tool is correctly reacting to the fact that the node
it has been instructed to find is not missing, but rather ambiguous.

I don't want to get too far off-topic, but a brief discussion of XML is in
order. An XML schema allows you to declare a node as optional, however not
all nodes can be optional. Is it one thing to declare a node at the top of
a hierarchy as optional. In that case, ADO responds by returning a DBNull
for the missing node. However, if a node that is within a certain
hierarchy in the document is declared as optional and is missing, it can
no longer be determined where the nodes above that node fit into the
hierarchy. In that case, ADO responds by returning the error : There is no
record at position <record numberor at least, that is what I believe is
happening. It is simply another way of saying that the node does not
validate.

For example, take the most extreme case, of declaring a root node as
optional. If the root node is missing in the document, there basically is
no document to read. A good schema tool should not allow certain nodes to
be declared as optional, but if the schema is being written by hand, that
case can exist.

So, to return to the problem that I currently face is that I have an XML
document with 50,000 records, and a few of them are missing tags in
inappropriate places. ADO insists on dumping out of the loop when it gets
to an invalid node, so I'm stuck. I need to find a way to test for an
invalid node (missing record) and ignore it, or ignore the exception and
continue on to the next record.

I'm going to try simply removing the Using statement surrounding the loop
and see what happens. If that doesn't work, I need help.

--
Regards,

Fred Chateau
http://hotelmotelnow.com

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:7C**********************************@microsof t.com...
>Your XML document breaks *what* schema? "There are missing tags
everywhere"..
*what* missing tags are we talking about here?

If you are getting a "There is no row at position <row number>" error, it
may likely be because there aren't any rows at all, so looking for a
workaround to "get the next row" may be futile.

Suggest you practice a bit on how to make clearer posts so readers can be
more help.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Fred Chateau" wrote:
>>Still working on my XML DataSet...

Having moved on past difficult and complex problems, resolved with the
assistance of everyone here, I find myself facing yet another problem.
My
XML document breaks the schema. There are missing tags everywhere, on
purpose I'm told, because we don't need them.

I'm getting a "System.Data: There is no row at position <row number>"
error.
Hopefully I can workaround this issue. I need to find a way to keep
going
past the missing row on to the next one, without throwing an exception.

Any suggestions?

--
Regards,

Fred Chateau
http://hotelmotelnow.com


May 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.