ajax
Posts: 5
|
Posted: 01/29/2009, 11:26 AM |
|
I have been having problem creating a custom session variable in vb.net
Basically, I have a users table which contains user login information. 'OfficeID' is a field on the users table and all I want to do is to add this field as a custom session variable when the user logs in. Here is the code:
System.Web.HttpContext.Current.Session("officeID")=(new IntegerField("",Settings.MyConnectionDataAccessObject.ExecuteScalar("SELECT officeID FROM Users WHERE user_login = '" & Session("user_ID") & "'"))).Value.
I create a form with a textbox to test the custom session variable; I set the default value to:
HttpContext.Current.Session("officeID"), but it returns empty. So I added 3 more textboxes to capture the user_id , groupID & user_login session variable , all returned correct except for the custom session variable , could someone help me out with this.
|
|
|
bobhuff
Posts: 21
|
Posted: 02/04/2009, 2:16 PM |
|
You may want to create a new TextField instead of IntegerField. Session variables value are a text type.
Best,
Bob
|
|
|
Tuong Do
|
Posted: 02/04/2009, 5:19 PM |
|
Your database lookup always return a NULL value
You should change
WHERE user_login = '" & Session("user_ID")
To
WHERE user_login = '" & Session("user_login ")
"ajax" <ajax@forum.codecharge> wrote in message
news:8498202ec24547@news.codecharge.com...
>I have been having problem creating a custom session variable .
> Basically, I have a users table which contains user login information.
> 'OfficeID' is a field on the users table and all I want to do is to add
> this
> field as a custom session variable when the user logs in. Here is the
> code:
>
> System.Web.HttpContext.Current.Session("officeID")=(new
> IntegerField("",Settings.MyConnectionDataAccessObject.ExecuteScalar("SELECT
> officeID FROM Users WHERE user_login = '" & Session("user_ID") &
> "'"))).Value.
>
> I create a form with a textbox to test the custom session variable; I set
> the
> default value to:
> HttpContext.Current.Session("officeID"), but it returns empty. So I added
> 3
> more textboxes to capture the user_id , groupID & user_login session
> variable ,
> all returned correct except for the custom session variable , could
> someone help
> me out with this.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
|