Solved

Does Dataset already exist

Posted on 2014-02-26
3
338 Views
Last Modified: 2014-02-28
is there any way to tell if a dataset already exists or has been created?  Something like:

ds = dataset

If ds.exists = true then
....
elseif ds.exists = false then
....
End if

Thanks
0
Comment
Question by:Mike_Stevens
3 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39889842
If your object equates to nothing (ds Is Nothing) then it has not been created. If you need to know if the object has been filled, you can check if the dataset contains any tables, and that the tables have rows.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39889893
If ds IsNot Nothing Then
   'DataSet has not been created (New was not called)
Else
   If ds.Tables.Count=0 then
      'The DataSet has been created but is empty
   Else
      'The DataSet has been created and contains at least one table
   End If
End If

This being said, do not make the mistake we encounter all over the Internet. If you have only one table, or if you do not use DataRelation objects to create relations between many tables, you do not need a DataSet. It just adds extra overhead. A DataTable object is sufficient in such a case.
0
 

Author Closing Comment

by:Mike_Stevens
ID: 39894587
Excellent help by both!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

929 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

15 Experts available now in Live!

Get 1:1 Help Now