Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Database connection in web app
Message
 
To
07/04/2011 09:42:16
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01506103
Message ID:
01506388
Views:
36
Tim,

Your last suggestion creating a property on the business object for userID is the only choice as far as I'm concerned. Based on what you have said here the mmAppBase object for a web application does not return userID using the following line:
string userId = mmAppBase.UserMgr.UserID;
Is this true? And I'm guessing its true due to the static nature of web apps. If not true, then I just need to figure out why this is not working for me. (You can see my other thread for this titled mmAppBase).

Lastly, once I have this userID, I need to run a stored procedure that will set the userID for the audit program. But the audit program works for this as long as the database connection is maintained. I need to also know when I issue the stored procedure (somewhere in the Business Object), will the database connection be maintained throughout the process up until the actual save takes place. If it doesn't, then this whole subject is moot.

Your help is always appreciated. Please send me what you have proposed if it is not too difficult.

Thanks.

Bob


>Bob,
>
>When the application is running live, you would want to pass in the actual user name of the logged in user. The business objects that are created are subclassed from ABusiness object, but you need to pass in that value from the application as each business object is created. This is a bit of a conundrum as it would be really nice to set a value in the business project level somewhere so it just always knows who the currently logged in user is. Problem is by design, the business objects do not have any knowledge (or reference) to the application level stuff.
>
>If this was not a web application you could create a static property somewhere in the business objects project (ABusiness object class) where the business objects as created could always get to it. You would have to set that only once after a login, but then with a web based, not such a solution.
>
>Also, there is availability to the value from a session variable in the web already, but that would mean your business objects would have web specific code. If that isn't a big deal to you, then you could possibly do that.
>
>The best solution might be to always have a parameter of the userID passed into the business objects when they are created. You could use a factory method to always create them and passing that value in automatically. This would mean adding a property to the ABusiness object that holds the UserId and thus is available to all busines objects. Then everytime you create a business object you need to be sure to set that value, but I would do this via a factory method so it always gets done.
>
>I could send you a couple of ideas via email if you would like.
>Tim
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform