About Me

My photo
Hello, I'm a technology geek looking to upgrade my programming skills. These are some of the things I'm learning along my journey.

Tuesday, June 26, 2012

Create a Database in Visual Studio

Create a new empty web site in Visual Studio by clicking on “File” ,selecting “New Web Site” and selecting “ASP.NET Empty Web Site” in the dialog box. Choose your preferred language in the upper left of the dialog box and create an appropriate name for your new web site. Click “OK”.



Make sure the “Server Explorer” or the “Database Explorer” is visible on the right hand side of the screen. If not, click on the “View” menu and select either “Server Explorer” or “Database Explorer”.

Make sure the “Solution Explorer” is visible on the right side by selecting the “Solution Explorer” tab and right click on the web site name. A menu should appear and select “Add new item...”. Scroll down the dialog box and select “SQL Server Database” and click “Add”. A message box will appear asking you to place the file in a separate “App_Data” folder. Click “Yes”. The new database should appear in the “Server Explorer” or “Database Explorer”.

 



Right click on “Tables” and select “Add New Table”. Create database column entries by filling in “Column Name”, “Data Type” and “Allow Nulls”. When finished, click “Save”. Choose a table name in the pop-up window and click “OK”.



 
Right click on the new table name in the “Server/Database Explorer” and select “Show Table Data”. Fill in appropriate sample data for each column created and you are done.





No comments:

Post a Comment