Re: Object in session question

From: Chris (Chris_at_discussions.microsoft.com)
Date: 02/03/05


Date: Thu, 3 Feb 2005 07:25:02 -0800

Well I have always used session values but have kept it to a select few. I
see in this app dozens upon dozens to control things as simple as a report
name on a single page. Setting and using them as <> "" and = "". Then I
thought that simple datagrid population could be improved using functions,
etc. but to pass the SQL statement around, etc. seemed over kill? I could be
wrong. And there is a view and SP for each activity, most occuring once (not
reused again in the app).
On a separate subject, I've been reading about keeping the logic in the
business layer and not using SP's. I wonder what the true loss in eff is?

Thanx everyone for the input. We learn something new everyday.

"Karl Seguin" wrote:

> 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") = ""
> >
> >
> >
>
>
>



Relevant Pages

  • Re: How do you figure out how much memory a class is using?
    ... Can you elaborate on how you control these with some sample code? ... Session, Viewstate, Cache, Application. ... > "Joe Fallon" wrote in message ... >> Jay, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Session Madness
    ... Well Kevin, whatever the truth behind the problem, your suggestion saved the ... > has something to do with why the Control is not being rendered as ... that it is not a good idea to store UI elements in Session. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IE hosted .NET control as webservice client
    ... The hosted controls know nothing about the session.To the best of my ... You could probably specify the session ID as one ... of the parameters within the tag so the control will then be able ... > I'v got a web aplication (many aspx and html pages), ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: IE hosted .NET control as webservice client
    ... The hosted controls know nothing about the session.To the best of my ... You could probably specify the session ID as one ... of the parameters within the tag so the control will then be able ... > I'v got a web aplication (many aspx and html pages), ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: When does web control events fire
    ... All I can tell you is, if you want to remove something from Session, remove ... > Right now I have some information that I stored in Session State. ... > like to remove these data after finishing with the control. ... > "Kevin Spencer" wrote in message ...
    (microsoft.public.dotnet.framework.aspnet)