Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Correct usage of ADO.Net in an ASP.Net environment

Reply
Thread Tools

Re: Correct usage of ADO.Net in an ASP.Net environment

 
 
Natty Gur
Guest
Posts: n/a
 
      07-15-2003
Hi,

First of all I personally prefer to separate between the logic and the
data layer. The data access layer (DAL) just handles the DB by talking
SQL. The business logic (BL) layer just handles logic. If BL needs data
he asks it from DAL.

Now, back to the applications architecture. Letís start with the reason
for the errors. The ASP.NET page is multi-threaded that mean that the
object that you declare to hold your BL (you declare it as class
variable) will be shared by all threads that process this page.
You also declare the Connection, Command and reader as class variable.
So if two page requests will call method of your BL class we can end up
with this situation. First request is busy populating datareader data.
if the second request ask to populate another Datareader you will get
error since there is just one Reader and he is busy right now.

My advice is to make the Command, Connect and reader as method
variables.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Heath Kelly
Guest
Posts: n/a
 
      07-21-2003
Thanks Natty,
however moving the command, connection and reader variables
to the method level has not had any positive effect. I did get some
good cutting and pasting practice happening.
Anyone else got any ideas?


Natty Gur <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Hi,
>
> First of all I personally prefer to separate between the logic and the
> data layer. The data access layer (DAL) just handles the DB by talking
> SQL. The business logic (BL) layer just handles logic. If BL needs data
> he asks it from DAL.
>
> Now, back to the applications architecture. Let?s start with the reason
> for the errors. The ASP.NET page is multi-threaded that mean that the
> object that you declare to hold your BL (you declare it as class
> variable) will be shared by all threads that process this page.
> You also declare the Connection, Command and reader as class variable.
> So if two page requests will call method of your BL class we can end up
> with this situation. First request is busy populating datareader data.
> if the second request ask to populate another Datareader you will get
> error since there is just one Reader and he is busy right now.
>
> My advice is to make the Command, Connect and reader as method
> variables.
>
> Natty Gur, CTO
> Dao2Com Ltd.
> 28th Baruch Hirsch st. Bnei-Brak
> Israel , 51114
>
> Phone Numbers:
> Office: +972-(0)3-5786668
> Fax: +972-(0)3-5703475
> Mobile: +972-(0)58-888377
>
> Know the overall picture
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
Reply With Quote
 
 
 
 
Natty Gur
Guest
Posts: n/a
 
      07-21-2003
Are you sure that you move the declaration of those objects (DB) ?

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture


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

Thread Tools

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
70-284 Lab Environment, Need Virtual Environment brooklynbridge508@hotmail.com MCSA 4 05-02-2007 09:49 AM
Setting an environment variable from another environment variable marcwentink@hotmail.com Java 5 04-04-2007 10:39 PM
Correct White Balance Doesn't Mean Correct Color?? jim evans Digital Photography 28 12-27-2005 05:10 AM
correct or not correct? Dan HTML 7 10-02-2003 10:16 PM
To correct my program. please, check to find errors and correct me. joon Java 1 07-08-2003 06:13 AM



Advertisments