Problem with Property holding value in a COM used in ASP?

I have a COM (VB) component that has several properties.  I use the properties to set the ID and PWD then call the method to retrieve the co name.  Now when I put msgbox in the COM I get the Company name and it stores fine with the Property but after I called the method I call the property to tell me the company name and the value is gone.  I put a msgbox to see what the property variable holds in the COM component and its blank.

Any ideas:

VB COM code:
Option Explicit

Public Enum USE_PROFILE_HOW
    USE_COMPANY_ID = 0
    USE_CLIENT_ID = 1
    USE_WORK_ORDER_NUMBER = 2
End Enum

'local variable(s) to hold property value(s)
Private mvarPassword As String 'local copy
'local variable(s) to hold property value(s)
Private mvarID As Long 'local copy

Private mvarSecurityID As Long 'local copy
'local variable(s) to hold property value(s)
Private mvarCompanyName As String 'local copy
Public Property Let CompanyName(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.CompanyName = 5
    mvarCompanyName = vData
End Property


Public Property Get CompanyName() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.CompanyName
    MsgBox mvarCompanyName
    CompanyName = mvarCompanyName
End Property

Public Property Get SecurityID() As Long
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.SecurityID
    SecurityID = mvarSecurityID
End Property

Public Property Let ID(ByVal vData As Long)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.ID = 5
    mvarID = vData
End Property

Public Property Let Password(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Password = 5
    mvarPassword = vData
End Property

Public Function Logon(enUseHow As USE_PROFILE_HOW)

    Dim oCommand As New ADODB.Command
    Dim oRecords As New ADODB.Recordset
    Dim oContext As ObjectContext
    Dim sStoredProc As String
   
On Error GoTo Err

    Select Case enUseHow
        Case USE_COMPANY_ID
            sStoredProc = "CompanyLogon"
        Case USE_CLIENT_ID
        Case USE_WORK_ORDER_NUMBER
    End Select
   
    Set oContext = GetObjectContext

    With oCommand
        .ActiveConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Datalect Client Support;Data Source=EA_SYSTEM"
        .CommandType = adCmdStoredProc
        .CommandText = sStoredProc
        .Parameters.Refresh
        .Parameters("@CompanyID").Value = mvarID
        .Parameters("@Password").Value = mvarPassword
        Set oRecords = .Execute
        mvarCompanyName = oRecords("CompanyName")
        mvarSecurityID = oRecords("SecurityID")
    End With
   
    MsgBox mvarCompanyName
    oRecords.Close
    oContext.SetComplete
   
    Set oContext = Nothing
    Set oRecords = Nothing
    Set oCommand = Nothing
    Exit Function
   
Err:
    oContext.SetAbort
   
    MsgBox "fail"
    Set oRecords = Nothing
    Set oCommand = Nothing
    Set oContext = Nothing
   
End Function

in the ASP File:

<%@ LANGUAGE=VBSCRIPT Transaction=Required  %>

<%
      Dim Quote
      Dim sCoName
      Quote = chr(34)
      
      Set oLogon = Server.CreateObject( "Client_Support_COM.Logon" )
      oLogon.Password = Request.Form( "PWD" )
      oLogon.ID = Request.Form( "ID" )
      oLogon.Logon(USE_CLIENT_ID)
      
      sCoName = oLogon.CompanyName
%>

<%      
      Sub OnTransactionCommit()
            Dim sURL
            
            sURL = "http://ea_system/Client_Support/app/main.asp?CoID="
            sURL = sURL & Request.Form( "ID" ) & "&CoName=" & sCoName & "&SecID=" & "1"
            Response.Redirect(sURL)
      End Sub
%>

<%
      Sub OnTransactionAbort()
            Response.Redirect( "http://ea_system/Client_Support/logon/logon.htm" )            
      End Sub
%>

<%
      Set oLogon = Nothing
%>


eric07Asked:
Who is Participating?
 
datacopConnect With a Mentor Commented:
make sure that you set the class to be persistable, and that you are saving the properties to the property bag.
0
 
Éric MoreauSenior .Net ConsultantCommented:
Isn't object destroyed after a SetComplete?
0
All Courses

From novice to tech pro — start learning today.