Re: Object in session question
From: Karl Seguin (_at_)
Date: 02/03/05
- Next message: Shawn Berg: "Re: Page "skins""
- Previous message: Alvin Bruney [MVP]: "Re: Impersonate in ThreadPool"
- In reply to: Chris: "Object in session question"
- Next in thread: Chris: "Re: Object in session question"
- Reply: Chris: "Re: Object in session question"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 3 Feb 2005 08:59:51 -0500
Chris,
Perhaps I misunderstood, but what do you see as the problem? Simply the use
of sessions? You said "isn't he putting a page into a session object?" not
sure what you mean by this, but no he isn't. He doesn't do
Session("CurrentPage") = Page ....
Sessions are bad only when used incorrectly. You haven't given us quite
enough scope to really pass judgement...I would guess that a lot of this
could probably be rewritten without sessions...and probably be better for it
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "Chris" <Chris@discussions.microsoft.com> wrote in message news:9E66F345-D9A1-4FB6-B803-E639ECC5A648@microsoft.com... > I'm on a project where the prevoius developer wrote code like below. I > thought stuff like this was bad? Isn't he putting a page into a session > object? And what we are trying to do is hit the db via a Stored Proc to > create a datatable in most cases. This seems like a waste to me. Is this good? > > Public Shared Function getSQL(ByRef thePage As Page) As ProjectName.SQLServer > > If thePage.Session("mySQLInit") = "1" Then > > Return thePage.Session("mySQL") > End If > > thePage.Session("mySQL") = New ProjectName.SQLServer > thePage.Session("mySQLInit") = "1" > > Return thePage.Session("mySQL") > End Function > > And then shoots to the SP to create datatable: > > Sub FillDataGrid(ByRef gridData As System.Web.UI.WebControls.DataGrid, ByVal > SQL As String, Optional ByVal bAddNew As Boolean = False) > > Dim cnn As SqlConnection = New > SqlConnection(ConfigurationSettings.AppSettings().Item("ConnectionString")) > > Dim dt As DataTable = New DataTable("") > Dim dr As DataRow > > Dim objDA As SqlClient.SqlDataAdapter > objDA = New SqlClient.SqlDataAdapter > > dt = ExecSQLReturnDT(SQL, objDA) > > If bAddNew Then > dr = dt.NewRow > dt.Rows.InsertAt(dr, 0) > gridData.EditItemIndex = 0 > End If > > gridData.DataSource = dt > gridData.DataBind() > > End Sub > > And I see dozens of this: > > page.Page.Session("psedit_PSHistoryID") = "" > > >
- Next message: Shawn Berg: "Re: Page "skins""
- Previous message: Alvin Bruney [MVP]: "Re: Impersonate in ThreadPool"
- In reply to: Chris: "Object in session question"
- Next in thread: Chris: "Re: Object in session question"
- Reply: Chris: "Re: Object in session question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|