SQL Server 2008 Basics & Connection with VS2010


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 1

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.

SQL Server Authentication

SQL Server Authentication

Windows Authentication

Windows Authentication

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.

SQL Server Menagement Studio

Step 4: To create a Database Right Click on the Databases and Click New Database

Create new database

Step 5: Now provide the database name as your wish. Here I am giving DatabaseTest.  And click OK

Enter Database name

Step 6: Now Expand the DatabaseTest. From there Right Click on the Tables and then click on new tables.

Create New Table

Create New Table

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.

Enter Column names and datatypes

Step 8: To set a Primary key Right Click on the right of the column name and select Set as a primary key.

Set Primary Key

Set up a Primary Key

Step 9: To Save this file Press CTRL+s and provide a table name to save.

provide table name

Provide a table name

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:

insert data into table

insert data into table

Now insert data as follow:

inserting data

inserting data

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.

Add Connection

Step 2: A new windows will appear. From there select Microsoft SQL Server. OK

Microsoft SQL Server

Microsoft SQL Server

Step 3: Now Type your PC-Name\SQLEXPRESS as the following figure.

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.

Step 5: Now in VS you will be able to see as following in Server Explorer. Thant means your visual studio is connected to sql server.Now your Visual Studio is connected with SQL Server. Enjoy.

Thanks.

About Razib Chandra Deb

I completed my BSc in CSE from CSE Department of KUET. Currently I am working as a Software Engineer in Samsung R&D Institute Bangladesh(SRBD). I am interested in image processing.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

43 Responses to SQL Server 2008 Basics & Connection with VS2010

  1. Rahul says:

    Thanks for Help,It so Great ,…….

  2. MB says:

    Thanks for Help,It so Great ,…….Thanks for Help,It so Great ,…….Thanks for Help,It so Great ,and Thank you.

    may you can help me to connect VS2010 to MySQL server installed in Ubuntu server.
    Thank you again.

    BR,

  3. mantappp
    this is what i looking for in 1 month

  4. Mohd Amir says:

    thanx a lot…
    this tutorial really help me very much..

  5. kaloyan says:

    Thank you very much. This was a very useful tutorial for beginners like me :).

  6. Wayne says:

    Thank you for this tutorial.
    Been looking for something like this for quite a while.

  7. oshin says:

    hey do u know how to display the content of the table present in sql in ms visual studio..i need the coding part..:)

  8. can other pc that run vb2010 connect to this database?? tq..

  9. arzib vai apni ki bengali? amar aro help lagbo, email id diben?

  10. ubersmench says:

    Hi! I’m stuck in this part (https://razibdeb.files.wordpress.com/2011/01/ms-sql.png) of your tutorial. My PC does not have ‘Microsoft SQL Server’ as one of the options. How do I fix this?

  11. Akansha says:

    nice thanks

  12. pratik says:

    thanks buddy…:)

  13. farid says:

    why my vb.net cannot identify server explorer?? i try to find in database explorer however, my MS.sqlClient not display??

    i hope you can give me the solution and the option to connect the server with vb.net

    thankss:

  14. farid says:

    thanks..
    i already find the solution.. it not about sql server 2008 r2 that i install, but its about the visual studio that i install..
    a bit difference between visual studio express and visual studio prof…
    so those who have same problem like me
    please go to this link : http://download.cnet.com/Microsoft-Visual-Studio-2010-Professional/3000-2212_4-10618634.html?tag=mncol;1

    i hope this can solve your problem to find “server explore”

  15. hira says:

    heloooooooooo
    ur post is excellent…
    plzzzzzzzzz tell me that how i can execute queries (add,delete,update after connection)

  16. NAGARAJRATHINARAJ says:

    thank u very much for ur post… now only i know how to connect the visual studio and Sql server 2008

  17. Ngowi D says:

    hi. thanx for the adds.. It works, How can I use the connection string to insert data into database.. Please Help…

    • dilaram khan says:

      how to insert delete and update a record in sql server 2008 through web form using c# language

  18. kelvin says:

    thanks for the post. it work to me

  19. Bhavin Patel says:

    ThanQ for this Solution……

  20. D dreamer says:

    Thank u so much,,God wil reward u for good. for dis ur posting

  21. Vinay says:

    Thanks Man

  22. rose says:

    excuse me sir. can you help me with my project. the add, update, delete doesnt function well in my program. do you have any sample programs that can add, edit, delete data from ms sql server 2008 r2? please help me.

  23. Shahid Khan says:

    Thanks Razib 🙂

  24. Raunak says:

    Can you coding explain the any project .net

  25. adam says:

    Hi

    I like your simplicity& clearance of your explanation.

    I am looking for tempelte desging for VS2010 or VS2010 , so u can import it & modify it

  26. Hi. Thanks for sharing this article. But i am unable to deploy sql server database in windows form application installer setup. Can you help in this issue.

  27. Sunil Thapa Magar says:

    Plz anybody tell me after above task what I have to do to access data. I mean any other settings or extra code needed or just write down the data access query?

  28. samonta says:

    Thank you.
    It help a lot.

  29. nikuuu says:

    Thanks alot really. Useful product

  30. Kirtan Panchal says:

    right bro and thanks…..

  31. Sagar Patil says:

    how to connect visual studio to sql server? i created website using visual studio in local host, i wont to connect website to sql database. how to do it?

Leave a reply to Rahul Cancel reply