Visual Studio 2003: Insert Connection String Macro
First....
Access the Visual Studio Macro Explorer and create a module.

Insert the following code in the module.
Imports EnvDTE
Imports System.Diagnostics
Public Module Module1
Public Sub InsertConnectionString()
Dim links As Object = CreateObject("DataLinks")
Dim cn As Object = CreateObject("ADODB.Connection")
links.PromptEdit(cn)
If cn.connectionstring = "" Then Exit Sub
Dim sel As TextSelection = ActiveDocument().Selection
sel.Text() = cn.connectionstring
End Sub
End Module
Then Save the macro.
When you are in a place during your coding that you wish to enter a connection string.
Execute the macro and it brings up the DataLink dialog box. which everyone using VS.NET should know how to use.

Upon hitting ok
Your connection string will be entered from the clip board into the code where your cursor location waas prior to executing the macro.
Which in this example was in between two quotes after the strConnnectionString assignment.

Enjoy!
The Ron
1 Comments:
Hey, Ron, very nice, but what about ADO.NET? I would guess that most developers would be using that with VS.NET>
Post a Comment
Subscribe to Post Comments [Atom]
<< Home