473,761 Members | 9,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nTier question regarding DataSets and DataReaders

I know how this should be done in regards to nTier, but it seems a bit
inneficient, and was wondering if there's a solution that I havn't thought
of yet.

(I'm switching this loop to For Each Row as DataRow in.... to kill the one
int that's not needed.)

For intCount1 = 0 To
objData.DataSet .Tables("tblSec ondaryNumbers") .Rows.Count - 1
rowTemp = objData.DataSet .Tables("tblSec ondaryNumbers") .Rows(intCount1 )
If intTempID <> rowTemp("Primar yID") Then
intTempID = rowTemp("Primar yID")
strDisplay += " arrSecondary[" & intTempID & "] = new Array();" & vbCr
End If
strDisplay += " arrSecondary[" & intTempID & "][" &
rowTemp("Second aryID") & "] = """ & _
rowTemp("Second aryNumber") & " - " & rowTemp("Type") & """;" & vbCr
Next
strDisplay += "</script>" & vbCr

That loop right there uses a DataSet that was passed back. However, it's
only used once, and it's Forward only. It seems logical that a DataReader
should be used instead, saving the resources.

Is using a DataSEt the best solution for it? I was thinking of sending back
an individual table, rather than create a DataSet. Wanted to throw it out
here to see if there was any better solution.
Nov 18 '05 #1
5 1178
Hi Ryan,

Microsoft has done a brilliant job of making people aware of the DataSet
class but a rather poor job of promoting the more lightweight data classes,
such as DataTable and DataReader. I'm not sure why, other than the fact that
there are a lot of lazy developers out there who just want their software to
run, and don't care all that much about performance, and are too lazy to
learn much more than one class if they can help it. The DataSet is a
one-size-fits-all class which can do much more than either DataTable or
DataReader. However, as you seem to notice, it also carries a much higher
resource cost. For example, a DataReader is used internally to populate a
DataSet. Obviously, the DataReader itself is much more compact. In addition,
a DataSet is not a table, but a rather complex container for multiple
DataTable objects. And in your code, you're only working with one DataTable
in the DataSet. So, a DataTable is more lightweight than a DataSet.

In your case, as you mentioned, you're moving through a single result set
forward-only. So, the most efficient solution for you would be to use a
DataReader.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Ryan Ternier" <rt******@icomp asstech.com> wrote in message
news:eM******** ******@TK2MSFTN GP10.phx.gbl...
I know how this should be done in regards to nTier, but it seems a bit
inneficient, and was wondering if there's a solution that I havn't thought
of yet.

(I'm switching this loop to For Each Row as DataRow in.... to kill the one
int that's not needed.)

For intCount1 = 0 To
objData.DataSet .Tables("tblSec ondaryNumbers") .Rows.Count - 1
rowTemp = objData.DataSet .Tables("tblSec ondaryNumbers") .Rows(intCount1 )
If intTempID <> rowTemp("Primar yID") Then
intTempID = rowTemp("Primar yID")
strDisplay += " arrSecondary[" & intTempID & "] = new Array();" & vbCr End If
strDisplay += " arrSecondary[" & intTempID & "][" &
rowTemp("Second aryID") & "] = """ & _
rowTemp("Second aryNumber") & " - " & rowTemp("Type") & """;" & vbCr
Next
strDisplay += "</script>" & vbCr

That loop right there uses a DataSet that was passed back. However, it's
only used once, and it's Forward only. It seems logical that a DataReader
should be used instead, saving the resources.

Is using a DataSEt the best solution for it? I was thinking of sending back an individual table, rather than create a DataSet. Wanted to throw it out
here to see if there was any better solution.

Nov 18 '05 #2
Kevin, Thanks for the reply. I know the DataReader would be a low
resource cost control, but I didn't think it was built to be passed
between logical tiers (business and Data).

I could see my Data Class using it to populate a DataTable,
but wouldn't it be better to just run a DataAdapert on that and fill my
DataTable, and throw that back to my Business Tier?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
its very bad pratice to return a DataReader from any layer. the creater of
the Reader should consume and release it. Otherwise you run into the
following problems:

1) lost resources if the reader is not deallocated correctly.
2) locking on the database because of delays in processing the reader. it
will hold database locks until its fully processed.
-- bruce (sqlwork.com)
"Ryan Ternier" <rt************ ******@icompass tech.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
| Kevin, Thanks for the reply. I know the DataReader would be a low
| resource cost control, but I didn't think it was built to be passed
| between logical tiers (business and Data).
|
| I could see my Data Class using it to populate a DataTable,
| but wouldn't it be better to just run a DataAdapert on that and fill my
| DataTable, and throw that back to my Business Tier?
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
I don't understand this. I thought Microsoft Data Access Block return
datareaders, dataset, etc back to the caller from their helper classes.
Could you post a little of pseudo-code or code to explain your position
about passing data throught tiers
Thanks

"bruce barker" wrote:
its very bad pratice to return a DataReader from any layer. the creater of
the Reader should consume and release it. Otherwise you run into the
following problems:

1) lost resources if the reader is not deallocated correctly.
2) locking on the database because of delays in processing the reader. it
will hold database locks until its fully processed.
-- bruce (sqlwork.com)
"Ryan Ternier" <rt************ ******@icompass tech.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
| Kevin, Thanks for the reply. I know the DataReader would be a low
| resource cost control, but I didn't think it was built to be passed
| between logical tiers (business and Data).
|
| I could see my Data Class using it to populate a DataTable,
| but wouldn't it be better to just run a DataAdapert on that and fill my
| DataTable, and throw that back to my Business Tier?
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #5
Well, Ryan, I may get slammed for this by some, but my data tier can return
all 3 types of classes: DataSets, DataTables and DataReaders. I just make
sure I close the DataReaders and their connections when I use them. But
that's just me. My Uncle Chutney always said "Neither a follower nor a
lender be," and I kind of took it to heart. By that same token, I would have
to tell you to decide for yourself what the best architecture for your
application would be.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Ryan Ternier" <rt************ ******@icompass tech.com> wrote in message
news:eK******** ******@TK2MSFTN GP09.phx.gbl...
Kevin, Thanks for the reply. I know the DataReader would be a low
resource cost control, but I didn't think it was built to be passed
between logical tiers (business and Data).

I could see my Data Class using it to populate a DataTable,
but wouldn't it be better to just run a DataAdapert on that and fill my
DataTable, and throw that back to my Business Tier?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #6

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

Similar topics

0
2693
by: William Ryan | last post by:
At the risk of sounding like a Big 5 consultant, "It depends". 1) Strongly typed datasets rock, they are faster than untyped, use intellisense... but your reason for wanting to use them is important. I use them every day of my life, but I also don't use them every day of my life and there are reasons for both. 2) How much of your process is dependent on reads vs.
0
1061
by: tstephan | last post by:
In the past we have used the classic nTier design with COM+, SQL Server and MFC. We are currently working on a new project with an opportunity to use .NET, ADO.NET, etc. One of the areas where I don't find a clear migration path is with security. In the classic method, the server side tiers were installed under COM+ and run as a known user. SQL Server then gave full access to this known user so ADO simply needed to make standard calls...
25
5061
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). The problem I found with this was circular referencing...
1
1054
by: Matt | last post by:
Hello, I'm working on a project in which i use Sql Server stored procedures to add and modify the records of our customers. This works fine, but when writing these stored procedures, i must use a lot of parameters (around 20) to add or modify a customer. It's long to write but i can deal with that. However, i was wondering if it is really efficient. In this case are stored procedures with many parameters better than using a dataset to
3
1727
by: Rob Thomas | last post by:
Hi, I've been tasked to come up with a new architecture for a large application at one of my customer's sites. In the past, I have developed multi-tier applications whereby the business objects maintain the database using stored procedures etc and provide the data to the GUI layer via a set of objects and collections. After using the typed datasets with .NET, it appears that you van provide the same functionality as objects and...
1
1027
by: Dnx | last post by:
hi i'm a very beginner of visual studio .net 2003 and aspx/vb.net i have to create a project with an architecture ntier i understand the concept but in practical, i don't know where to begin... please help me thank you
16
1937
by: Luqman | last post by:
Is it recommended to use datasets in ASP.Net 2.0 / VS.Net 2005 ? Best Regards, Luqman
0
912
by: Jon Vaughan | last post by:
Hello, I have an NTIER Model written in VB.NET, at the moment is running as a client / server. Pushing a pulling data from the client to the server is fine and is done via webservice calls. But how do I go about a call from the server to the clients ? An example would be that the clients are using a disconnected dataset and need to be informed that the dataset has been altered and needs refreshing.
0
886
by: Teo | last post by:
Hey guys!! I am looking at a user friendly tutorial on how to use Dataadapters, datatables and datasets to fill datagrids, etc. I am confused on using them a lot. Now I mostly use Datareaders and Nonqueries to enter and retrieve data in and out of DB. Please help. Thanks, Teo
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.