Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB6
Expertise: Intermediate
May 5, 1999

Let the user build a connection string

You can programmatically display the standard DataLink property dialog box to let the end user manually build a connection string, that you can later assign to the ConnectionString of an ADO Connection object.

To do so you must add a reference to the Microsoft OLE DB Service Component 1.0 Type Library. By default this library isn't added to the References dialog box, so you probably have to click on the Browse button inside that dialog, and navigate to the oledb32.dll file, that you should find in the c:\Program Files\Common Files\System\ole db directory. After you have added this reference you can display the standard Data Link dialog using this code:


Dim dataLink As New MSDASC.DataLinks
Dim connString As String
Dim cn As New ADODB.Connection

' The following statement makes the property modal respect to the current form
dataLink.hWnd = Me.hWnd
' Display the dialog
On Error Resume Next
connString = dataLink.PromptNew
If Err = 0 Then
    ' Create a Connection object on this connection string
    cn.ConnectionString = connString
Else
    ' User canceled the operation
End If
You can also display the same dialog to let the user edit the connection string of an existing Connection object. You do this using the PromptEdit method:

If dataLink.PromptEdit(cn) Then
    MsgBox cn.ConnectionString
Else
    MsgBox "Operation canceled"
End If
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date