Solved

Datatable check if exists

Posted on 2009-07-15
3
508 Views
Last Modified: 2012-05-07
How can I check if a datatable exists - am trying to use the below but fails when the table is empty

                if (ds.Tables[2].Rows.Count > 0)
In c#
0
Comment
Question by:tbaseflug
  • 2
3 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 24860315
are you sure that ds.Tables[2] is there

check for

ds.Tables[2] == null
0
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
ID: 24860334
if(ds.Tables.Count > 2)
{
if(ds.Tables[2] != null && ds.Tables[2].Rows.Count > 0)
{
}
}
0
 
LVL 22

Expert Comment

by:p_davis
ID: 24860810
so just b/c i didn't layout the entire code i get stiffed.

rock on.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now