SQL Azure: First Steps

With the wave of cloud technologies on the rise, the most notable that I have found has been SQL Azure. A big problem that I have seen with centralized database has always been performance. While developing Azure type applications, you can have a central database with complete control over client experience and still maintain excellent performance.

Accessing SQL Azure is as simple as modifying your connection string and pointing it to the right database that is provided from your cloud environment. There are some changes which are not supported in the cloud such as CLR development and redundancy management, which should not be an issue because the cloud system is responsible for data integrity.

For a great example of how to access data in the cloud, and typically any other SQL environment, check out this page on the msdn.

In this example, they use a connection string builder class which is an excellent class if you are use to typing out your connection strings or using connectionstrings.com

Here is an example of how to use the builder efficiently in your code:

// Create a connection string for the master database
    SqlConnectionStringBuilder connString1Builder;
    connString1Builder = new SqlConnectionStringBuilder();
    connString1Builder.DataSource = "server"; //your server name
    connString1Builder.InitialCatalog = "master"; //your database
    connString1Builder.Encrypt = true; //encrypt connection information
    connString1Builder.UserID = userName; //sql username
    connString1Builder.Password = password; //sql password

Once you have this object setup, you can use the ToString method of the object to retrieve a proper connection string for any object you like to use in your SQL data queries. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>