Help and Support

How To Invoke a Login Prompt When Opening an ADO Connection

Article ID:200886
Last Review:July 1, 2004
Revision:1.1
This article was previously published under Q200886
On This Page

SUMMARY

This article describes how to control a Data Provider's Login prompt.

Back to the top

MORE INFORMATION

To control a Data Provider's login prompt set the "Prompt" property exposed through the Properties collection of the Connection object to one of the four pre-defined constants or values as follows:
   adPromptAlways = 1
   adPromptComplete = 2
   adPromptCompleteRequired = 3
   adPromptNever = 4
				
The constants specify whether to always prompt, prompt if more information is needed, prompt if more information is needed but optional parameters are not allowed, or never prompt.

Different Login prompts will be presented depending on what Data Provider is specified in the Connection's Provider property. The default Data Provider for ActiveX Data Objects (ADO) is the OLE DB Provider of ODBC (MSDASQL).

Back to the top

Sample Code

Example 1
   Dim cn as ADODB.Connection
   Set cn = New ADODB.Connection
   With cn
      .Properties("Prompt") = adPromptAlways
      .Open
   End With
				
In Example 1, when the Open method is called, the ODBC Login prompt appears every time regardless of what the ConnectionString property may hold.

Example 2
   Dim cn as ADODB.Connection
   Set cn = New ADODB.Connection
   With cn
      .Provider = "SQLOLEDB"
      .Properties("Prompt") = adPromptComplete
      .ConnectionString = "DATA SOURCE=<server name>;"
      .Open
   End With
				
In Example 2, the Provider property is set to "SQLOLEDB", so the OLE DB Provider for SQL Server Prompt is presented to the user instead of the ODBC Login Prompt.

The constants can be found in the Adovbs.inc file. By default this file is located in the \\Program Files\Common Files\System\ADO subdirectory.

Back to the top

REFERENCES

For more information, please see the following article in the Microsoft Knowledge Base:
193128 (http://support.microsoft.com/kb/193128/EN-US/) How To ODBC and OLEDB Connection Prompt Control in ADO

Back to the top


APPLIES TO
Microsoft ActiveX Data Objects 1.5
Microsoft ActiveX Data Objects 2.0
Microsoft ActiveX Data Objects 2.01
Microsoft ActiveX Data Objects 2.1 Service Pack 1
Microsoft ActiveX Data Objects 2.5
Microsoft ActiveX Data Objects 2.6
Microsoft ActiveX Data Objects 2.7

Back to the top

Keywords: 
kbhowto KB200886

Back to the top

Article Translations

 

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.