Solved

Does Dataset already exist

Posted on 2014-02-26
3
341 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

765 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