Results 1 to 10 of 10

Thread: Session Confusion

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Session Confusion

    I have a ASP.net applcation, written in C#, that is producing some very
    strange behaviour.
    Information is stored in a SQL Server 2000 database. The page that records
    and stores information to the database functions correctly if only one user
    is using the application. However, if there is more than one user the
    system seems to get confused.
    The stored procedure that saves the new items returns the ID of the new
    item, via @@IDENTITY, this is then used by the page to populate itself from
    the database. If two people are using the system the one who submits his
    data second gets the first persons id back and his page populates with the
    other persons data. The system functions correctly for the first person.
    I simply do not understand how the @@IDENTITY value can be passed from one
    SQL Server session to an ASP.net session that did not create it.
    I've removed all session variables and record the @@IDENTITY value in a
    hidden field on the page.
    Anyone have any suggestions?

  2. #2
    Member
    Join Date
    Oct 2004
    Location
    India
    Posts
    53

    Re: Session Confusion

    try passing some input parameter to the stored procedure...you may use user id for this purpose..
    Yash

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Session Confusion

    Quote Originally Posted by yashsays
    try passing some input parameter to the stored procedure...you may use user id for this purpose..
    A varchar parameter is passed to the stored procedure, but I don't see how not passing a parameter would make any difference.

    I've also tried using SCOPE_IDENTITY() instead of @@IDENTITY.
    Still getting the errors.

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Session Confusion

    How about creating your own Session ID? Just a bunch of random alphanumeric characters that are stored along with the row in the DB.
    When you're pulling data back out just amend to your SQL query to check for the Session("MySessionID")
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Session Confusion

    Quote Originally Posted by plenderj
    How about creating your own Session ID? Just a bunch of random alphanumeric characters that are stored along with the row in the DB.
    When you're pulling data back out just amend to your SQL query to check for the Session("MySessionID")
    Tried something similar, added a table that the sproc wrote the new IDENTITY to, the sproc is working correctly, it added the correct values.
    I'm convinced that the problem lies with the communiction between the application server and the database server.
    The errors only occur when the application is run directly through IE not when trying to debug it in V.S.

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Session Confusion

    Could it perhaps be a cookies issue? i.e. if Windows XP SP2 was installed or something then perhaps its disallowing cookies being stored on the machine as default...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  7. #7

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Session Confusion [Resolved]

    I'm a plonker!

    I'd mistakenly declared the DataSet, that holds the data to display, as 'static'.

    As I'm an ex VB programmer I'm used to 'shared' meaning shared and static meaning things maintain their value for a particular instance.
    Now I've got loads of code to check to see how many times I've made the same stupid error.
    Deep joy.

  8. #8

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Session Confusion

    Anyone know how to declare a DataSet that will only need to be populated on the first load event of the page and maintain its value for subsequent loads?

  9. #9
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Session Confusion

    Look into Caching DataSets.

  10. #10

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Session Confusion

    Quote Originally Posted by wey97
    Look into Caching DataSets.
    I've decided storing the DataSet in a session variable is the way to go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width