J
Jon Maz
Hi,
I'm facing a code-optimisation issue on an asp.net/vb.net/SQL Server 2000
project. A web page containing not much more than 3 DropDownLists is taking
nigh on 6 seconds to load, because each ddl opens up a separate connection
to the DB, pulls out its data, and closes its own connection before the next
ddl repeats the process.
The code to handle each DDL's connection to the DB is packaged in an object
(presentation-layer code below); two of the hits go via a Person object, and
one via a User object. Both these objects are separated into a business
layer and a data layer.
My optimisation goal is to have all these three DB hits done on just one DB
connection. The only way I can think of doing this would be:
* create a connection object in the presentation layer (more likely, an
SqlCommand object which contains an open connection),
* pass this open connection to
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC")
* the presentation layer gets the open connection back from
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC"), laden with data
* the pres layer takes out the data, fills up DDL1 with it, and passes the
still-open-connection to Wec.User.GetAllOrderBy("LastName", "DESC")
* the open connection comes back once more to the presentation layer, laden
with the second batch of data
* DDL2 is filled up with this data, and the process repeats for DDL3
* once the pres layer has got all the necessary data it kills the connection
I dare say I could adapt the various Business and Data Layer routines to
handle this. My main worry is about violating the OOP principle of layer
separation - if I'm going to start creating SqlConnections / SqlCommands in
my *presentation layer*, I might as well slit my OOP wrists right now....
Any input welcome!
TIA,
JON
'DDL1
ddlIntroducerNames.DataSource =
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC")
ddlIntroducerNames.DataTextField = "WholeName"
ddlIntroducerNames.DataValueField = "PersonID"
ddlIntroducerNames.DataBind()
'DDL2
ddlWECReps.DataSource = Wec.User.GetAllOrderBy("LastName", "DESC")
ddlWECReps.DataTextField = "WholeName"
ddlWECReps.DataValueField = "UserID"
ddlWECReps.DataBind()
'DDL3
ddlIntroducedBy.DataSource = Person.GetAllActivesOrderBy("LastName", "ASC")
ddlIntroducedBy.DataTextField = "WholeName"
ddlIntroducedBy.DataValueField = "PersonID"
ddlIntroducedBy.DataBind()
I'm facing a code-optimisation issue on an asp.net/vb.net/SQL Server 2000
project. A web page containing not much more than 3 DropDownLists is taking
nigh on 6 seconds to load, because each ddl opens up a separate connection
to the DB, pulls out its data, and closes its own connection before the next
ddl repeats the process.
The code to handle each DDL's connection to the DB is packaged in an object
(presentation-layer code below); two of the hits go via a Person object, and
one via a User object. Both these objects are separated into a business
layer and a data layer.
My optimisation goal is to have all these three DB hits done on just one DB
connection. The only way I can think of doing this would be:
* create a connection object in the presentation layer (more likely, an
SqlCommand object which contains an open connection),
* pass this open connection to
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC")
* the presentation layer gets the open connection back from
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC"), laden with data
* the pres layer takes out the data, fills up DDL1 with it, and passes the
still-open-connection to Wec.User.GetAllOrderBy("LastName", "DESC")
* the open connection comes back once more to the presentation layer, laden
with the second batch of data
* DDL2 is filled up with this data, and the process repeats for DDL3
* once the pres layer has got all the necessary data it kills the connection
I dare say I could adapt the various Business and Data Layer routines to
handle this. My main worry is about violating the OOP principle of layer
separation - if I'm going to start creating SqlConnections / SqlCommands in
my *presentation layer*, I might as well slit my OOP wrists right now....
Any input welcome!
TIA,
JON
'DDL1
ddlIntroducerNames.DataSource =
Person.GetAllActiveNonIntroducersOrderBy("LastName", "ASC")
ddlIntroducerNames.DataTextField = "WholeName"
ddlIntroducerNames.DataValueField = "PersonID"
ddlIntroducerNames.DataBind()
'DDL2
ddlWECReps.DataSource = Wec.User.GetAllOrderBy("LastName", "DESC")
ddlWECReps.DataTextField = "WholeName"
ddlWECReps.DataValueField = "UserID"
ddlWECReps.DataBind()
'DDL3
ddlIntroducedBy.DataSource = Person.GetAllActivesOrderBy("LastName", "ASC")
ddlIntroducedBy.DataTextField = "WholeName"
ddlIntroducedBy.DataValueField = "PersonID"
ddlIntroducedBy.DataBind()