|
-
Mar 30th, 2005, 06:58 AM
#1
Thread Starter
Hyperactive Member
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?
-
Mar 30th, 2005, 09:55 AM
#2
Member
Re: Session Confusion
try passing some input parameter to the stored procedure...you may use user id for this purpose..
-
Mar 30th, 2005, 10:01 AM
#3
Thread Starter
Hyperactive Member
Re: Session Confusion
 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.
-
Mar 30th, 2005, 10:11 AM
#4
Retired VBF Adm1nistrator
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]
-
Mar 30th, 2005, 10:19 AM
#5
Thread Starter
Hyperactive Member
Re: Session Confusion
 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.
-
Mar 31st, 2005, 03:18 AM
#6
Retired VBF Adm1nistrator
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]
-
Mar 31st, 2005, 03:54 AM
#7
Thread Starter
Hyperactive Member
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.
-
Mar 31st, 2005, 04:20 AM
#8
Thread Starter
Hyperactive Member
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?
-
Mar 31st, 2005, 09:34 AM
#9
Frenzied Member
Re: Session Confusion
Look into Caching DataSets.
-
Mar 31st, 2005, 09:38 AM
#10
Thread Starter
Hyperactive Member
Re: Session Confusion
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|