ASP.NET SessionID

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 14-Apr-2006 02:12:14   

I'm trying to store the asp.net session id in a table/entity and keep getting an error on insert stating the the SessionID field cannot be null. I don't understand why this is happening since I can debug this and see that the entity field SessionID has the 32 char value. Here is the DDL for the table, anyone have any ideas?

Here is the code that I'm using.


protected void Session_Start(Object sender, EventArgs e)
{
    WSSessionEntity session = new WSSessionEntity();
    session.SessionID = this.Session.SessionID;
    session.StartDate = DateTime.Now;
    ServiceFactory.GetPersistanceManager().SaveEntity(session);
}

DDL


CREATE TABLE [dbo].[WSSession] (
    [SessionID] [char] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [StartDate] [datetime] NOT NULL ,
    [UpdateDate] [datetime] NOT NULL 
) ON [PRIMARY]
END

GO

ALTER TABLE [dbo].[WSSession] ADD 
    CONSTRAINT [DF__WSSession__Start__32D8D1C3] DEFAULT (getdate()) FOR [StartDate],
    CONSTRAINT [DF__WSSession__Updat__33CCF5FC] DEFAULT (getdate()) FOR [UpdateDate],
    CONSTRAINT [PK_WSSession] PRIMARY KEY  NONCLUSTERED 
    (
        [SessionID]
    )  ON [PRIMARY] 
GO

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 14-Apr-2006 02:45:34   

When you debug ServiceFactory.GetPersistanceManager().SaveEntity you have a value for SessionID? Can you post the trace the occurs during the save?

Thanks, Brian

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 14-Apr-2006 02:52:58   

bclubb wrote:

When you debug ServiceFactory.GetPersistanceManager().SaveEntity you have a value for SessionID? Can you post the trace the occurs during the save?

Thanks, Brian

Is this the trace information you wanted? I think my problem might be where it says "@SessionID=SCOPE_IDENTITY()" since I'm not using an identity as the PK.

Method Enter: EntityBase2.ValidateValueCustom
Active Entity Description: 
    Entity: WrenchScience.LLBLGen.EntityClasses.WSSessionEntity. ObjectID: abb4ef8b-b2e5-46ca-b8a3-a0e8ec7ddfa8
    PrimaryKey field: SessionID. Type: System.String. Value: 
Entity Validation Result: True
Method Exit: EntityBase2.ValidateValueCustom
Method Enter: EntityBase2.ValidateValueCustom
Active Entity Description: 
    Entity: WrenchScience.LLBLGen.EntityClasses.WSSessionEntity. ObjectID: abb4ef8b-b2e5-46ca-b8a3-a0e8ec7ddfa8
    PrimaryKey field: SessionID. Type: System.String. Value: rrb0fmymz1jiio45cesujc55
Entity Validation Result: True
Method Exit: EntityBase2.ValidateValueCustom
Method Enter: EntityBase2.Validate
Active Entity Description: 
    Entity: WrenchScience.LLBLGen.EntityClasses.WSSessionEntity. ObjectID: abb4ef8b-b2e5-46ca-b8a3-a0e8ec7ddfa8
    PrimaryKey field: SessionID. Type: System.String. Value: rrb0fmymz1jiio45cesujc55
Entity Validation Result: True
Method Exit: EntityBase2.Validate
Method Enter: CreateInsertDQ
Method Enter: CreateSingleTargetInsertDQ
Generated Sql query: 
    Query: INSERT INTO [WS2].[dbo].[WSSession] ([StartDate]) VALUES (@StartDate);SELECT @SessionID=SCOPE_IDENTITY()
    Parameter: @SessionID : AnsiStringFixedLength. Length: 32. Precision: 0. Scale: 0. Direction: Output. Value: rrb0fmymz1jiio45cesujc55.
    Parameter: @StartDate : DateTime. Length: 0. Precision: 23. Scale: 3. Direction: Input. Value: 4/13/2006 5:52:38 PM.

Method Exit: CreateSingleTargetInsertDQ
Method Exit: CreateInsertDQ

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 14-Apr-2006 03:03:04   

You're right I believe. Did it used to be an identity column? You should be able to go into the designer and unselect the identity checkbox. If not then you may have to remove the entity from the project and add it again. Can you please check what version you are running? I somewhat remember an bug like this being around a month or so ago.

Thanks, Brian

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 14-Apr-2006 18:57:17   

I believe the version I'm using is 1.0.2005.1 Final. I just deleted the entity from the designer and re-added it and the problem has been fixed. Maybe I need to update the version I'm using.