A common scenario is reading user ID and passwords stored in session variables from within a component to avoid passing them as parameters. Note that your application becomes more scalable by avoiding state in Session (see the REFERENCES section in this article for more information). With this in mind, stress test your application before you move you application from development to production.
- Open a new ActiveX DLL project.
- Set a reference to the Microsoft Transaction Server (MTS) Type Library (Mtxas.dll).
- Set a reference to the Microsoft Active Server Pages Object library (Asp.dll).
- Rename the project as prjMTS and class as clsMTS.
- Copy the following code to the clsMTS:
Dim objApplication As Object
Dim objSession As Object
Public Function GetVar() As String
Dim objCtx As ObjectContext
Set objCtx = GetObjectContext
Set objApplication = objCtx.Item("Application")
Set objSession = objCtx.Item("Session")
GetVar = objApplication("Var1") & objSession("Var2") & "..."
- Create a blank new ASP page under one of virtual directories and add this code to it:
Application("Var1") = "Where do you want"
Session("Var2") = "to go today ?"
Set obj = Server.CreateObject("prjMTS.clsMTS")
Set obj = Nothing
- When you run this ASP page, the variables set in the page are accessed inside the Visual Basic component and the following appears in the browser:Where do you want to go today ?
ID d'article : 230149 - Dernière mise à jour : 14 août 2008 - Révision : 1