HOWTO: ODBC and OLEDB Connection Prompt Control in ADOID: Q193128
|
This article demonstrates how to prompt a user for ODBC connect string
information such as Server, User ID, Password, Trusted_Connection,
Language, and Database using ActiveX Data Objects (ADO).
The article also shows how to display an OLE DB Data Link dialog box to select an OLEDB provider and its properties.
Dim conn As ADODB.Connection
Dim strConn As String
' Assign the connection string to a variable.
strConn = "DRIVER={SQL Server};SERVER=;UID=;PWD=;DATABASE="
' Create the Connection object.
Set conn = New ADODB.Connection
'Assign the connection string and provider, then open the connection.
With conn
.ConnectionString = strConn
.Provider = "MSDASQL"
' Valid Enums for the ADO Prompt property are:
' adPromptAlways = 1
' adPromptComplete = 2
' adPromptCompleteRequired = 3
' adPromptNever =4
.Properties("Prompt") = adPromptAlways
.Open strConn
End With
Private Sub btnRunTest_Click()
Dim conn As New ADODB.Recordset
Dim dl As New MSDASC.DataLinks
conn = dl.PromptNew
Debug.print conn.ConnectionString
End Sub
Additional query words: ADO ODBC OLEDB PROMPT DataLink
Keywords : kbADO100 kbADO150 kbADO200 kbDatabase kbODBC kbOLEDB kbProvider
Version : WINDOWS:1.0,1.5,2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 17, 1999