VB and VBA Users Source Code: How to visually create an ADO/OLEDB connection string
[
Home
|
Contents
|
Search
|
Reply
| Previous |
Next
]
VB/VBA Source Code
How to visually create an ADO/OLEDB connection string
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, September 30, 2002
Hits:
1933
Category:
Database/SQL/ADO
Article:
If you can't remember the syntax for creating and OLEDB (ADO) connection string then use the following code to show a dialog and return the connection string for the settings you enter: Option Explicit 'Purpose : Displays a dialog to enable you to visually create an OLEDB (ADO) connection string 'Inputs : N/A 'Outputs : Returns the OLEDB connection string for the settings stored in the dialog 'Author : Andrew Baker 'Date : 20/Sep/2002 18:17 'Notes : Useful if you can't remember the syntax for creating OLEDB (ADO) connections 'Revisions : 'Assumptions : Function OLEDBConnectionStringCreate() As String Dim oDataLink As Object 'MSDASC.DataLinks Dim oCon As Object 'ADODB.Connection On Error Resume Next Set oDataLink = CreateObject("DataLinks") If oDataLink Is Nothing = False Then Set oCon = CreateObject("ADODB.Connection") Call oDataLink.PromptEdit(oCon) OLEDBConnectionStringCreate = oCon.ConnectionString Else Debug.Print Err.Description Debug.Assert False End If Set oCon = Nothing Set oDataLink = Nothing End Function 'Demonstration routine Private Sub Command1_Click() Debug.Print OLEDBConnectionStringCreate End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder