How to Create Code for the ProfileRefresh Subroutine in Visual Basic .NET (816081)



The information in this article applies to:

  • Microsoft Commerce Server 2002

For a Microsoft Visual C# .NET version of this article, see 815700.

SUMMARY

When you create a new Commerce Server Microsoft ASP.NET Web application in Microsoft Visual Basic .NET by using Microsoft Visual Studio .NET, the code that is generated does not contain all the code that is required for the ProfileRefresh subroutine to function correctly. Also, the documentation does not contain the information that you must have to write this code.

MORE INFORMATION

In the source code of the RefreshApp.aspx (RefreshApp.aspx.vb) file, the code that is generated causes the ProfileRefresh subroutine to fail. The following is the default code:
Sub ProfileRefresh()
        ' Implement Profile Service Refresh here
        ' Please see the Profile Service documentation for more information on
        ' implementing a refresh of the Profile Service

        ' This will cause "Publish failed" to appear in the Business Desk application status
        Err.Raise(1)
End Sub
If you use the default Profiling System, you can replace the default code with the following code to provide valid ProfileRefresh functionality. To do this, follow these steps:
  1. Add the following references to the code:
    	Imports Microsoft.CommerceServer.Runtime
    	Imports Microsoft.CommerceServer.Runtime.Profiles
  2. Replace the existing code with the following sample code:
    Sub ProfileRefresh()
            Dim profilesContext As ProfileContext
            Dim bdaoConnectionString As String
            Dim providerConnectionString As String
            Dim profilesConnectionString As String
            bdaoConnectionString = CommerceApplicationModule.Resources("Biz Data Service")("s_BizDataStoreConnectionString").ToString()
            providerConnectionString = CommerceApplicationModule.Resources("Biz Data Service")("s_CommerceProviderConnectionString").ToString()
            profilesConnectionString = CommerceApplicationModule.Resources("Biz Data Service")("s_ProfileServiceConnectionString").ToString()
            profilesContext = New ProfileContext(profilesConnectionString, providerConnectionString, bdaoConnectionString, CommerceContext.Current.DebugContext)
            CommerceProfileModule.ProfileContext = profilesContext
    End Sub

Modification Type:MajorLast Reviewed:9/12/2003
Keywords:kbhowto KB816081 kbAudDeveloper