Wednesday, October 26, 2005 6:50 AM
Speaking of usefull macros, this is one I've used for a a few years and thought might be usefull. It calls the ADODB Data Link Properties dialog (shown below). After you go through the dialog picking your data source, database, and connection settings, it dumps out the connection string for your configuration into code window where your cursor is located.

Here is the code for the connection string macro:
Public Sub ConnectionStringWizard()
Dim args() As Object
Dim linkType As System.Type = System.Type.GetTypeFromProgID("DataLinks")
Dim linkObj As Object = Activator.CreateInstance(linkType)
Dim conObj = linkType.InvokeMember("PromptNew", System.Reflection.BindingFlags.InvokeMethod,
Nothing, linkObj, args)
If conObj Is Nothing = False Then
Dim constring As String = conObj.GetType().InvokeMember("ConnectionString", System.Reflection.BindingFlags.GetProperty, Nothing, conObj, args).ToString()
Dim textSelection As TextSelection = DTE.ActiveDocument.Selection()
Dim edit As EditPoint = textSelection.TopPoint.CreateEditPoint()
edit.Insert("""" & constring & """")
End If
End Sub