473,614 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7469
Hi,

"UJ" <fr**@nowhere.c om> wrote in message
news:%2******** *******@tk2msft ngp13.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("Tabl e 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1709
by: Got2Go | last post by:
Hello, I am trying to come up with a function that will search the source of the page for a specific string. If that string is found, then have it modify specific tags inside of a table and display a link on the page. This link, when clicked will then restore the modified tags back to their original values.
1
1727
by: David | last post by:
Hello, I use the VS .NET 2003. Say I have a Windows form (with C# code, of course) which is connected to a database to one table. I can browse through the records, but I don't know how to accomplish a search for a specific record. I would like to have a button that by clicking it, a response window will be opened. Say that the search will be according a specific column of the table, so by filling a value to a Text Box for that column and...
1
1629
by: Shapper | last post by:
Hello, I have am connecting a datagrid to a dataset: dgProducts.DataSource = dsProducts() dsProducts is a function which returns a dataset. How can I detect if the dataset which is being returned is empty? Thanks,
1
4226
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
1
1240
by: Brian | last post by:
Hello - Im new to ADO.NET so bear with me here. I have an Access DB, simplified as follows: TABLE Person person_ID autonumber PK last_name text first_name text
3
14934
by: Anthony Bowman | last post by:
Hello, I have a access application that resides locally on users desk, I am writing a VB.Net interface that let's the users pull data down from a SQL server database and populate the local access database with that data, I need to check the local access database to see if there is already a table with the name the users give. Anyone run into that or have any idea how this would be done. Thanks Anthony
1
13642
by: jaya_rath | last post by:
Check table's existance -------------------------------------------------------------------------------- How can I check if a table exists in an MS SQL database using asp.plz help me . advance thanx <% Option Explicit %> <% Response.Buffer=True %> <!--#include File ="Include/Connection.asp" -->
14
2126
by: Dan | last post by:
Hello, we have an intranet application using Windows Integrated Authentification. When an user starts the application, he gets a form for inputting data. The first time he does that, the application creates in a specific database a table with the name of his account (read with Request.ServerVariables("remote_user") and creates in that table the records he enters. From the second time the user starts the application, still the same form...
1
1398
by: Cirene | last post by:
Using VB.NET (latest version) I want to log onto an FTP server and check for the existance of 10 files in 3 different directories. I would prefer to do this over 1 live connection. Anyone have any sample code that does this? (The code samples that I've seen connects via a FtpWebRequest to a specific URI (which includes a filename) and just checks if GetFileSize produces an error which contains 550. I'm not sure if this is the most...
0
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8287
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.