PC Review


Reply
Thread Tools Rate Thread

Dataset empty or is nothing?

 
 
=?Utf-8?B?cGhsYWtpZQ==?=
Guest
Posts: n/a
 
      18th Jul 2005
Excerpt from Code:

dim ds as new dataset

ds= execute("Stored_Proc")
dim name as string= ds.tables(0).datasetname

execute is a function that executes the stored procedure Stored_Proc.

Suppose execute returns an empty dataset, what kind of exception is raised?

 
Reply With Quote
 
 
 
 
Norman Yuan
Guest
Posts: n/a
 
      18th Jul 2005
Asume the "execute()" function returns an empty DataSet
(DataSet.Tables.Count=0), the next line of code

dim name as string= ds.tables(0).datasetname

will always raise exception, because DataTable does not have a property
called "datasetname" (it has property called "TableName").

Maybe it is your typo and you meant "TableName". If so, that line of code
will raise "Object reference not set...." exception, because "Tables[0]"
does not exist.

"phlakie" <(E-Mail Removed)> wrote in message
newsA103219-E87A-47AD-BFF6-(E-Mail Removed)...
> Excerpt from Code:
>
> dim ds as new dataset
>
> ds= execute("Stored_Proc")
> dim name as string= ds.tables(0).datasetname
>
> execute is a function that executes the stored procedure Stored_Proc.
>
> Suppose execute returns an empty dataset, what kind of exception is

raised?
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      18th Jul 2005
As others have noted, there is no "datasetname" property.
However, there are two situations that you need to be ready for.
1) The query returns no rows. In this case you'll get a new DataTable but
the Rows.Count property will be 0.
2) The query returns no rowset. If you execute an action query or the SP
executes logic that bypasses the SELECT, you will get a resultset, but no
rowset. In this case the DataTable will not be created at all.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
www.sqlreportingservices.net
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________


"phlakie" <(E-Mail Removed)> wrote in message
newsA103219-E87A-47AD-BFF6-(E-Mail Removed)...
> Excerpt from Code:
>
> dim ds as new dataset
>
> ds= execute("Stored_Proc")
> dim name as string= ds.tables(0).datasetname
>
> execute is a function that executes the stored procedure Stored_Proc.
>
> Suppose execute returns an empty dataset, what kind of exception is
> raised?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
empty dataSet Toyin Microsoft ADO .NET 1 5th Dec 2007 06:36 PM
is dataset empty Rock Microsoft ADO .NET 2 2nd Nov 2004 12:59 AM
checking if the dataset is empty? sean Microsoft ADO .NET 9 22nd Jun 2004 02:51 AM
empty dataset Eva Microsoft Dot NET 1 11th Jan 2004 10:25 AM
Add to an Empty DataSet Jim Microsoft ADO .NET 2 3rd Jan 2004 02:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.