Archive

Archive for October, 2010

Create new Table in SQL Server 2008 R2

October 31, 2010 Leave a comment

In this post, I’ll be guiding you how to create a new table in Microsoft SQL Server 2008 R2. In this demo, I’ll be using Microsoft SQL Server 2008 R2 Express Edition. I assume you already have a existing database. If you do not, please see this post first.

Now, lets get started.

  1. Run the Microsoft SQL Server Management Studio and login to your database engine.
  2. On the “Object Explorer” expand “Databases” menu, and then also expand your database menu by clicking on the “+” icon next to each respective folders.
  3. Right-Click on “Tables” and select “New Table”.
  4. A new window will then comes up next to the “Object Explorer”. Now enter your column name, data type, and allow nulls.
  5. You can make a column as a Primary Key by just keeping your cursor on the column that you want to make it a Primary Key, and then click on the Key icon on the Toolbar.
  6. When you’re done, hit the “Save” button on the toolbar or just simply press "Ctrl+S” to save. Then Microsoft SQL Server will prompt you to give your table a name. Enter a name and click “OK"04-CreateNewTable2

That’s it. You have just created a new table in your database in Microsoft SQL Server 2008.

Creating a new database in Microsoft SQL Server 2008 R2

October 31, 2010 1 comment

In this post, I’ll be guiding you how to create your first database with Microsoft SQL Server 2008 R2. For this demo, I’ll be using Microsoft SQL Server 2008 R2 Express Edition.

First, you have to download and install Microsoft SQL Server 2008 R2 Express Edition. You can either download the 32-bit version or the 64-bit version. [ Download here ]

*NOTE: Download the version with Management Tools.

 

After you have completed your download and installed in on your PC, lets get started.

  1. Click start, and search for “SQL Server Management Studio” and run the program.
  2. You will now be prompt to login into your Database Engine. Depending on what type of login method you specified during the installation, you can either logon using Windows Authentication or SQL Server Authentication. In my case, I’ll be using Windows Authentication.
    01-ConnectToDatabaseEngine
  3. After you have successfully logged in, click on “Databases” to see all your existing Databases. If this is your fresh installation, you will only be able to see “System Databases” folder there.
    02-ListOfExistingDatabase
  4. Now, to create your own database, Right-Click on “Databases” on the left column, and select “New Database..”. Then, you should see a pop-up window to create a new database.
    03-CreateNewDatabase2
  5. Enter your database name. For our case now, we’ll just leave other settings with the default values. If you already have some experience with Microsoft SQL Server, you can proceed to do your preferred settings. Hit “OK” after you have done all your settings and you’ll see your database listed on the left panel under “Databases”.
    03-CreateNewDatabase3
  6. Now, let’s see what do we have in our new database here by clicking on the “+” icon on the left panel next to our database name. You should be able to see 8 different types of folders, such as “Database Diagrams”, “Tables”, and etc.

And that’s it. You have just created a new database with Microsoft SQL Server 2008 R2.

Additional:

If you’re wondering where is your database file located in your PC, by default it’s located in:

C:\Program Files\Microsoft SQL Server\MSSQL10.1SQLEXPRESS\MSSQL\DATA

How to: Encrypt/Decrypt web.config

October 17, 2010 Leave a comment

When you are developing a ASP.NET Web Application, you know that the web.config file is a very important file to your web application. This is because, it contains all/part of your application settings, such as connection strings. So, when you have completed developing your web application and wants to deploy it to the server, you might want to encrypt the web.config file first. This is to make sure that nobody knows what is the content in that web.config file if they manage to get a copy of it. Well of course IIS will not allow any request to view/download the web.config file.

You can encrypt/decrypt the web.config file at any time. Take note that you can ONLY decrypt an encrypted web.config file on the machine that encrypted the web.config. Here is several ways of how you can encrypt your web.config files:

Encrypt

  1. Open up a Command Prompt.
    For Windows XP: press Win+R, then type in “cmd” and hit Enter.
    For Windows Vista/Windows 7: Press start and type “cmd” in the search bar. Click on the “Cmd” program.
  2. Navigate to the the directory “C:\Windows\Microsoft.NET\Framework\v2.0.50727\
  3. Then, type in the following:
    aspnet_regiis -pe “connectionStrings” -app “/SampleApplication” -prov “RsaProtectedConfigurationProvider”

NOTE:

This sample above is to encrypt the “connectionStrings” section for the application “SampleApplication” using the provider “RsaProtectedConfigurationProvider”.

 

Decrypt

  1. Open up a Command Prompt.
    For Windows XP: press Ctrl+R, then type in “cmd” and hit Enter.
    For Windows Vista/Windows 7: Press start and type “cmd” in the search bar. Click on the “Cmd” program.
  2. Navigate to the the directory “C:\Windows\Microsoft.NET\Framework\v2.0.50727\
  3. Then, type in the following:
    aspnet_regiis –pd “connectionStrings” -app “/SampleApplication”
Categories: ASP.NET Tags: , , ,