Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

When vb.net call a stored procedure and not data is returned dataset is not nothing Expand / Collapse
Author
Message
Posted Friday, December 13, 2013 8:42 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, December 8, 2014 9:37 AM
Points: 10, Visits: 75
what exactly is returned to VB.NET from a called stored procedure when no data is found?
Post #1522726
Posted Friday, December 13, 2013 8:58 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:09 AM
Points: 13,323, Visits: 12,806
SqlBound (12/13/2013)
what exactly is returned to VB.NET from a called stored procedure when no data is found?


That depends on the procedure AND the .NET code. I will make some assumptions based on the title of your post.

Assuming your code is getting a DataSet AND that your procedure has a single select statement to return a single dataset...

If the above is true then you will get a DataSet with a single table that matches the definition of the query but it will not have any rows.

MyDataSet.Tables[0].Rows.Count = 0
MyDataSet.Tables[0].Columns.Count = the number of columns in the select statement in your procedure.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1522739
Posted Friday, December 13, 2013 10:50 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:09 AM
Points: 13,323, Visits: 12,806
You should post your replies here instead of private message.

All you need to do to check if there is no data returned is to look at the row count for the table.

if MyDataSet.Tables[0].Rows.Count = 0 then
'There are no rows
else
'There are rows
end if

--Not sure if my VB syntax is correct but it is close.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1522803
Posted Friday, December 13, 2013 10:53 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 5:24 AM
Points: 128, Visits: 490
It may also depend on what data you're returning. Are you looking for a set of records or a single value? If you can be more specific we can help.

Mark



Post #1522805
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse