Active Directory Products
Calls To Calendar
SMS To CSV
SMS To Gmail
Voicemail To Gmail
How Long For Me
<< Back To All Blogs
Friday, November 3rd, 2006
I deal with lots of different kinds of Connection Strings in my applications, whether it be from my legacy MySql server still backing the majority of my site, Sql Server 2000 or Sql Server 2005 on some of the newer parts, or a DB2 or PostgreSQL connection that I'm using on a side-project. A problem I often run into is forgetting how to construct the proper connection string for each server type. Granted they are somewhat similiar, but oftentimes not interchangeable. So... my solution: write a program that you can pass generic values, such as username, password, etc to a class I created, call a function with an enum to return the proper connection string. As a coded example:
ConnectionStringBuilder builder = new ConnectionStringBuilder("myUsername", "myPassword", "myServer", "myDatabase");
string connString = builder.GetConnectionString(ConnectionStringTypes.Oracle);
Or, a shorter by-pass method that I am growing on without actually instantiating a full object is:
string connString = new ConnectionStringBuilder("myUsername", "myPassword", "myServer", "myDatabase").GetConnectionString(ConnectionStringTypes.Oracle);
I'll be posting the code to this as well as a bunch of other projects I've been working on lately once I get my new dorky site up for posting code.
That's all for now folks!
Reading A Database Schema in SQLite with C#
Implementing AJAX with PHP and MySQL
Writing console output from a Windows form in C#
Programatically Retrieving an Assembly's PublicKeyToken through a PowerShell CmdLet
Creating a reusable web client for PUT, POST, and DELETE in C#
Currently no comments.
Add A Comment
Email Address: (not public, used to send notifications on further comments)
Enter the text above, except for the 1st and last character: