Does Dataset already exist

Posted on 2014-02-26
Medium Priority
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

Question by:Mike_Stevens
LVL 27

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.
LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 39889893
If ds IsNot Nothing Then
   'DataSet has not been created (New was not called)
   If ds.Tables.Count=0 then
      'The DataSet has been created but is empty
      '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.

Author Closing Comment

ID: 39894587
Excellent help by both!

Featured Post

Easily manage email signatures in Office 365

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

607 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