In my previous post I show how to install SQL Server 2008. You need to install SQL Server 2008 SP1. I don’t install it yet. In this post I am going to show
1. Some basics of SQL server management studio with connection.
2. Connect Visual Studio 2010 with SQL Server 2008
Now I am going to start:
Step 1: Go to Start Menu then find Microsoft SQL Server 2008 then SQL Server Management Studio.
Step 2: A window will open from which you have to login to Database Engine to perform any operation. Here for the authentication we have two option Windows Authentication, SQL Server Authentication. I select mixed mode in my installation process. So that I am able to login in both way. For SQL Server Authentication we need Username and Password. For username we have to use “sa” and password which we provide in the time of installation.
Step 3: After clicking connect it will connect to database engine. And then a window will open where in the object explorer it will show some databases which has been created by default.
Step 4: To create a Database Right Click on the Databases and Click New Database
Step 5: Now provide the database name as your wish. Here I am giving DatabaseTest. And click OK
Step 6: Now Expand the DatabaseTest. From there Right Click on the Tables and then click on new tables.
Step 7: Now under the column add column name and its data type. If you do not want to allow null value the uncheck the Allow Nulls.
Step 8: To set a Primary key Right Click on the right of the column name and select Set as a primary key.
Step 9: To Save this file Press CTRL+s and provide a table name to save.
Insert Or Updating data of table:
To insert or update data right click on the table name and select Edit Top 200 Rows as follows:
Now insert data as follow:
In this way you can insert update data. to delete data right click on the left side of row and select delete to delete data.
Now I am going to show you the way to connect Visual Studio 2010 with MS SQL.
Step 1: Open Visual Studio and Open a project. Here I am not going to show how to open a project of ASP.NET or Web Application I will post it later. To know how to connect you need not to open a project. Now come to the point. First of all from the View menu select Server Explorer to show the server explorer if you do not already show it.
Step 2: A new windows will appear. From there select Microsoft SQL Server. OK
Step 4: If you want to use Windows Authentication then check Use Windows Authentication or if you want to use SQL server Authentication then check it and provide username (sa) and password (which you provide during installation). Now click on the Test Connection button to test every thing is ok or not? If there is no error then select a database from the dropdown list and press OK.