Click here to Skip to main content
Licence 
First Posted 16 May 2005
Views 32,707
Bookmarked 29 times

SQL ConnectionInfo Class

By | 16 May 2005 | Article
A class for building SQL connection strings from specified properties. Class can also parse SQLConnection.ConnectionString() into properties using the parse method. Code is fully commented and handles all SQLConnection.ConnectionString properties.
 
Part of The SQL Zone sponsored by
See Also

Sample Image - demobuilder.gif

Sample Image2 - demoparser.gif

Introduction

I wrote this class to help developers with building and updating SQL Connection strings. The ConnectionInfo class can parse and build strings through properties and methods of the ConnectionInfo class. The ConnectionInfo class has two methods. The first method ConnectionInfo.Parse(string), parses SQL Connection strings into ConnectionInfo() properties.

i.e

//Parsing Code-----------------------------------
ConnectionInfo Info = new ConnectionInfo();
Info.Parse("Initial Catalog=Northwind;Data Source=localhost;Integrated Security=SSPI;");
MessageBox.Show(Info.DataSource);
//-----------------------------------------------

The second method ConnectionInfo.ToString(), builds a string out of all the available ConnectionInfo() properties.

i.e

//Building Code----------------------------------
ConnectionInfo Info = new ConnectionInfo();
Info.DataSource = "localhost";
Info.InitialCatalog = "Northwind";
MessageBox.Show(Info.ToString());
//-----------------------------------------------

Terms & Conditions

THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

References

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassTopic.asp

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

VectorX

Software Developer (Senior)
Codevendor
United States United States

Member

Please visit my personal website http://www.codevendor.com for my latest codes and updates.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionany update ?? Pinmemberalhambra-eidos0:04 25 Sep '08  
QuestionWhy not just create a UDL file? PinmemberChristopher Scholten18:40 17 Jul '05  
GeneralA small bug and some suggestions Pinsussdesynch14:53 9 Jul '05  
GeneralRe: A small bug and some suggestions Pinmemberalhambra-eidos1:07 25 Sep '08  
QuestionWhat is the standard connection ? PinmemberTrance Junkie23:00 31 May '05  
1) What is the standard connection string format used in sql.
2) Should i put this connection in a web.config file when dev an asp.net app?
Thanks in advance !;)
AnswerRe: What is the standard connection ? PinmemberVectorX6:54 1 Jun '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120528.1 | Last Updated 16 May 2005
Article Copyright 2005 by VectorX
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid