471,354 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Check for the existance of a specific table in a dataset.

UJ
I'm getting a dataset back from a web service and I want to verify that the
table I want exists before trying to access it (which will cause an
exception.) Is there an easy way to check for a specific table in my dataset
without doing a try/catch or is that the easiest way?

TIA - Jeff.
Jan 25 '06 #1
2 7334
Hi,

"UJ" <fr**@nowhere.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I'm getting a dataset back from a web service and I want to verify that
the table I want exists before trying to access it (which will cause an
exception.) Is there an easy way to check for a specific table in my
dataset without doing a try/catch or is that the easiest way?


if ( dataSet.Tables["MyTable"] == null )
throw new exception("Table no present");

in other words, just check for null when you refer to the table, the same
apply to columns

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 25 '06 #2
You can do what Ignacio says or there is also a "Contains" attribute
from the table and column collections to verify the existence of a
member before accessing it.

_Randal

Jan 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Shapper | last post: by
3 posts views Thread by Anthony Bowman | 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.