CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Session Variable

Print topic Send  topic

Author Message
mr_medhat

Posts: 16
Posted: 08/24/2006, 3:11 PM

Gentlemen ,

There is something wrong in the Codecharge documentation code about creating custom Session Variables :

It is :

VB.NET
'Button Button_DoLogin Event OnClick. Action Custom Code

Session("User_Name") = Settings.Connection1DataAccessObject.ExecuteScalar("SELECT User_Name FROM Users WHERE User_ID=" &
Settings.Connection1DataAccessObject.ToSql(DBUtility.UserId.ToString(), FieldType._Integer))


The part of ( ToSql ) Doesn’t return a value , and the browser gives the error :
(Exception Details: System.NullReferenceException: Object reference not set to an instance of an object)


If I replace the (ToSql) section with a specific value ( Ex. 1 ) I get the correct User_Name of the user with an ID of 1 .

I appreciate your help.
View profile  Send private message
mr_medhat

Posts: 16
Posted: 08/26/2006, 5:43 AM

After all the testing I made ,

1 ) If I put the Custom Code OnClick event before the login OnClick Event , Then , The problem lies in the fact that UserId is not already known before the actual login occur , so , DBUtility.UserId doesn’t return a thing !!!!

2) If I Put the Login event first , The redirecting to the referenced page occur before the Session Variable is initiated !!!!


Any Suggestions ?
View profile  Send private message
mr_medhat

Posts: 16
Posted: 08/26/2006, 6:17 AM

I Finally solved it ;-) I just moved the custom code from the OnClike Event of the logon Button to the After Unload event of the page ;-)) it’s working fine .

Here is the custom code in case anyone needs it :

Session("Variable_Name") = Settings.Connection1DataAccessObject.ExecuteScalar("SELECT Column_Name FROM Users WHERE User_ID ="& Settings.Connection1DataAccessObject.ToSql(DBUtility.UserId, FieldType._Integer))


All the best for everyone .:-)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.