This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
By Cayce Chismar,
Hello everyone, this time we start a new series where we will post some more of the great content from our college in Microsoft Test Team (Principal Customer Engineer) boB 'the ToolMan' Taylor, who is an industry expert in all topics SQL. The theme of this series will be "Helpful SQL Tools and Tips to make your life as Test Engineer" (or Developer, QA, etc.), really anyone who spends time working with SQL.
As some of you may know, we have featured content from boB before, such as his "Learning Justo Query Language" video tutorials. If you are interested in that, please don't miss our post.
Today we will review a tool he created to make the life easier for anyone who spends a lot of time working on SQL Server Management Studio (SSMS). This tool will allow you a quicker and more efficient way to connect to several SQL Servers through SSMS.
When working on SSMS, connecting many different SQL Server instances can get repetitive, having to enter information, Server Name, credentials, etc. each time. If you know a little C# and SQL Management Objects then boB has constructed a Connect To SQL class to help 'connect to any SQL Server instance along with any SQL Azure Database server instance’. The Connect to SQL base class is imported and your class will be derived from this base class. This is meant to be a simpler way to connect to a database, using an UI that looks familiar rather than going through C# config files.
Let’s do a quick walk through of this tool:
Connect to SQL Base
In boB's method, the user will have access to open a connection and any Connection Information needed to perform tasks. boB created a 'Connect to SQL Base' class to be added into your project that lessens inputting data repeatedly, such as Server Name and credentials. This is also useful if a person does not know the name of which database they are needing to connect to; this class will go out and search through all available databases and allow you to pick which database you would like to use. Within boB's ConnectToSQLBase class, there are two standard resources: a default icon for use by the dialog and a default banner for use by the dialog.
Let's dive into the code that connects our database and determines the correct Authentication method!
First, capture the current cursor and set wait cursor. Then create a ServerConnection object based on the ServerName in the cbServerName ComboBox.
Based on the AuthMethod selected in the cbAuthentication ComboBox, modify the ServerConnectionInfo object with the appropriate information.
Line 11 calls the DoWork() method, which needs to be implemented in your derived class.
"Note: you must set the minimum SQL Server version number that you want prior to the following call which fills the cbServer drop-down list. You can set this value in your constructor. It currently defaults to 12."
That is all, we hope this information is useful, please follow links below for the source code and original posts and let us know of any questions in the comments section below. Thanks!
The original Archive code is on boB Taylor's GitHub
Other interesting resources in boB's blog::
- Connect To SQL… a utility for C# programmers | boB 'The ToolMan' Taylor (sqlbobt.com)
- Connect To SQL… a utility for C# programmers– Part 2 | boB 'The ToolMan' Taylor (sqlbobt.com)
- SqlCommandFilters–a tool for every toolbox | boB 'The ToolMan' Taylor (sqlbobt.com)
Thank you all for reading, we hope this information is helpful. Please leave any questions or comments in the section below!