Data Connection Dialog

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a VB 6.0 function that displays the Data Link wizard and returns the
user built data connection string and it has worked beautifully for years. I
have taken this vb6 function upgraded and wrapped it in VB.NET. Still works
great! Problem: I would like to use the new data connection wizard like the
one that VS05 provides. I have found the reference to
Microsoft.VisualStudio.Data.Dataconnectiondialog, however I am having
problems constructing and using this reference...Can anyone provide a snippet
using this reference or provide another .net reference for obtaining a user
built connection string.

Code:
Public Function GetConnnectionStringFromUser() As String
'uses the data link API connection dialogbox
'lets the user specify the connection to the database
'dependent on MSDASC - DLAPI
'dependent on ADODB for the use of the connection object
'if successfull returns the connection string
'if FAILS returns empty string
'no error checking done here to validate connection string

Dim oDataLink As New MSDASC.DataLinks
Dim oConn As ADODB.Connection
Dim strReturn As String

Try
' Display the Data Link Dialog
oConn = oDataLink.PromptNew
If oConn Is Nothing Then
'user pressed cancel
strReturn = String.Empty
Else
strReturn = oConn.ConnectionString
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
strReturn = String.Empty
Finally
oDataLink = Nothing
oConn = Nothing
End Try
Return strReturn
End Function
 
Back
Top