The Ron's Blog

Ok this is where I'm putting the HUMOR and other NON-Technical Rants. Ok I call it humor. Others might not.... Whatever your view point. You have your right to it. So try to enjoy. That is my intent. Life is too short not to laugh.

My Photo
Name:
Location: National Park, New Jersey, United States

"The Ron" is very into his wife Cindi and his home life. They've raised some really cool children who are tech savvy. I'm a major computer "geek" myself who started on hardware side of analog and digital electronics in late 70' and early 80's. I'm currently programming in C# (C Sharp not C Octothorp). I started in software on PC side with CPM and DOS 1.0 using Assembler and C. I'm currently a software developer working in Business Intelligence and Enterprise Software Development with a Fortune 100 company. I like outdoor nature stuff, cooking on the grill and comedy of all types. This helps balance the hard core geek in me. Oh yea... Semper Fi !! "You can take man out of Marine Corps but not Marine Corps out of man."

Monday, August 07, 2006

Visual Studio 2003: Insert Connection String Macro

In order to have a handy connection string creator added to your VS.NET for figuring out and inserting a string just where you need it in your code. I'm supplying this handy 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:

Blogger Rich said...

Hey, Ron, very nice, but what about ADO.NET? I would guess that most developers would be using that with VS.NET>

7:36 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home