473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Why DataSet not out of scope?

Say you create a DataSet in a function in your Data Access layer, then pass
it back to your business layer, why is it not out-of-scope in your business
layer?

If you look at the below article, it states
"If you declare a variable within a procedure, but outside of any If
statement, the scope is until the End Sub or End Function. The lifetime of
the variable is until the procedures ends."

http://msdn2.microsoft.com/en-us/library/ms973875.aspx
Oct 26 '07 #1
1 979
Billy expressed precisely :
Say you create a DataSet in a function in your Data Access layer, then pass
it back to your business layer, why is it not out-of-scope in your business
layer?

If you look at the below article, it states
"If you declare a variable within a procedure, but outside of any If
statement, the scope is until the End Sub or End Function. The lifetime of
the variable is until the procedures ends."

http://msdn2.microsoft.com/en-us/library/ms973875.aspx
The *variable* may be out of scope, but that doesn't automatically
invalidate the object that is was pointing to.
Your function returns a DataSet (or rather a reference to that DataSet)
so the dataset will remain "alive" as there still is a reference to it.
And you *have* that reference (the return value from your Data Access
call), so you can still access that DataSet.

If you don't keep that reference somehow, the dataset the variable was
pointing to will be eligible for garbage collection as soon as the
(last) variable pointing to it goes out of scope.

Hans Kesting
Oct 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anita C | last post by:
Hi, I have an xml document (Xml1.xml) with the foll.structure: <?xml version="1.0" encoding="utf-8"?> <REPORTS> <SCOPE TITLE="My Reports"> <REPORT URL="Report1.aspx" AUTHOR="me">First...
7
by: Jason Huang | last post by:
Hi, The SQL string is "select * from Customer where 0 > 1", and the DataSet should be null. Why MyDataSet.Tables.Count is 1, not 0? What kind of DataTable in this place? Thanks for help. ...
2
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and...
3
by: Arthur Dzhelali | last post by:
Is there any way to cache dataset on one page and it will be accessible for one user? if you declare dataset shared it will stay on the server and page will be able reference to it on reload,...
1
by: Nikhil Patel | last post by:
Hi all, If I want to access the contents of a DataSet in multiple ASP.Net form requests without manually saving it in Cache, do I have to add the DataSet to the form at design time or can I just...
7
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and...
5
by: Wayne Wengert | last post by:
I have a Winform in VSNET 2003 where I define a dataadapter and fill a dataset in the form load event. When a user clicks on a "Save" button I want to do some validation, save updated values to the...
4
by: Looch | last post by:
Hi All, I'm using the following to fill a DataSet: public void itemSearch(string column, string item) { ...fill DataSet } I want to be able to move to the next and previous rows with:
7
by: =?Utf-8?B?QWxla3MgS2xleW4=?= | last post by:
I use in my asp.net code dataset and populate datatable using dataadapter. The problem is that my code demand huge amount of memory and I am looking for way reduce this demand. At this time I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.