How to connect a Visual Studio 2010 website to SQL Server 2005

7k Views Asked by At

I need to connect Visual Studio 2010 website to SQL Server 2005. My web site is ASP.NET using C#, on the .NET Framework 2.0

I googled it for hours and every site i entered the information didn't seemed relevant.

Maybe I just don't understand.

I would appreciate if someone showed me from where to begin.

For example: I created a login form using login control from the toolbox but don't know how to continue from here, how do I get the password and username from the database?

3

There are 3 best solutions below

0
Tim On

First order of business should be setting up a connection string for your database in web.config. Carl Prothman has a ton of information on setting this up.

You'd then create a database connection, log in using your connection string, and do something. Macon State has some excellent tutorials to get you going.

0
sathishkumar On

To create a connection string follow my-steps:

  1. First drag a sqldatasource to a .aspx page
  2. Go to design part of that .aspx page
  3. Then mouse over on the sqldatasource, there you will find a option like "configure datasource".just click on that.
  4. It will give you popup, there you should give your db credential and select a db
  5. click next and select one table(whatever it may be) and write some query or select some column VS offer to you and click next
  6. NOW IT WILL ASK, WHETHER YOU WANT SAVE THIS CONNECTION SETTINGS.Here you can give the connection string name and click ok.(now you can delete that sqldatasource)
  7. now go to web.config and see the connection configuration.

    If you want to use registered users and logins in your application, Use Asp.net membership.For more Info Use Membership in ASP.NET 2.0

0
Code Scratcher On

Follow below steps to connect a Visual Studio 2010 website with SQL Server 2005

Step 1 : Go to View > Server Explorer/Database Explorer

Setp 2 : Right click on Data Connections > Add Connection...

Step 3 : Select Server name, Choose authentication type, Select your created database.

Step 4 : Test your connection and then OK.

Also check below link for more understanding....

http://www.codescratcher.com/asp-net/bind-gridview-in-asp-net/

http://www.codescratcher.com/sql-server/overview-sql-server-database/