Solved

Datatable check if exists

Posted on 2009-07-15
3
513 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Increment column based of a FK 8 22
SQL server vNext 18 29
SQL2016 to ORACLE11G linked-server 6 15
Proper Case SQL Command 2 9
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

777 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