Microsoft KB Archive/198378

From BetaArchive Wiki
Knowledge Base


HOWTO: Use the VB DataEnvironment In Your MTS Components

Article ID: 198378

Article Last Modified on 3/14/2005



APPLIES TO

  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition
  • Microsoft Transaction Services 2.0



This article was previously published under Q198378

SUMMARY

The Visual Basic DataEnvironment was designed, tested, and configured to run as end-user product on a client workstation. It assumes an interactive desktop and user profile, and does not provide the level of reentrancy or security that is necessary to meet the needs of server-side components that are designed to run unattended. Microsoft does not currently recommend, and does not support, running the VB DataEnvironment from any unattended, non-interactive server application.

If you want to use the Visual Basic DataEnvironment to communicate with your database in your Transaction Server components, be sure to set the connection objects so that no prompt occurs if the attempt to connect fails.

MORE INFORMATION

By default, the DataEnvironment sets connections so that if the attempt to login fails, a dialog box appears to inform the user of the problem and allow the user to try to connect successfully.

If you are building a Transaction Server component, you do not want to use this feature for the following reasons:

  • Your Microsoft Transaction Server (MTS) component is usually running on another server and the user never sees this dialog box.
  • Connection pooling does not support this type of login.
  • Transaction Server will not enlist this connection in the component's transaction.

If you use ActiveX Data Objects (ADO) code, rather than the DataEnvironment to connect to your database, these problems will not occur. By default, ADO connections generate errors.

Here are two ways to make sure that your DataEnvironment connection will not display a dialog box if the login fails:

  • At design time, use the Properties Window (rather than the properties pages) to set the RunPromptBehavior property of the DataEnvironment connection to 4 - adPromptNever.
  • At run-time, set the Prompt property of the connection object as in the following code:

          DataEnvironment1.cnPubs.Properties("Prompt").Value = adPromptNever
          DataEnvironment1.cnPubs.Open
    
                            


REFERENCES

c) Microsoft Corporation 1998, All Rights Reserved. Contributions by David Sceppa, Microsoft Corporation

Keywords: kbhowto kbdataenv KB198378