Free Consultation - Call 305 403 0899
Skip Navigation Links
Tutorial

Connection String for MS SQL database

Publish date: Wednesday October 01, 2008
Database C# connection string C# database
Connecting to Database connection string web.config

This article shows how to connect from your web application to SQL Server database. In a few steps you can learn how to configure database server and make changes in your application configuration file (web.config) to get access to SQL database server from your web application.

After you have created database in MS SQL Server 2005 you need to add user in whose name the connection will be established. To do this open object explorer, extend the “Security” folder and select “New Login” by right clicking on the “Logins” folder.

You will see a new window called “Login – New”. On the “General Page” fill in login name for application user, check “SQL Server authentication” mode, enter password for application user, uncheck “User must change password at next login”, and select default database to which your application user will be connecting.

Next select “User Mappings” Page and check the “Map” field next to the database that you use in your web application. At the bottom you will see role membership for selected database. Check  db_datareader for getting data (run the SELECT statement), db_datawriter to add, delete and change data in database, and db_owner to access database objects like stored procedures.

The last thing you need to do is change web.config in your web application. You need to add connectionString section in the global “configuration” section.

In your application you can get the connection string using similar syntax:

Author: Pawel Matuszewski

Latest Tutorials Click here to see All Tutorials
How to upload videos on YouTube

How to upload videos on YouTube

08-09-10 - by Michal Sadowski

A vast majority of YouTube visitors come to watch rather than broadcast themselves, but it is the active minority who make the largest Internet video service tick.


Malgorzata Szabelska

Flash tutorial - How to send data to ASP.NET and read the answer

10-31-08 - by MaƂgorzata Szabelska

In this article I am going to present one possibility of sending data from flash site to ASP.NET and how from ASP.NET respond to FLASH.


Repeater_ASP.NET

ASP.NET Tutorial. How to use Repeater

10-28-08 - by Mariusz Siergijewicz

In this article, I'll show you how to use Repeater in ASP.NET page.


C# connection string

Connection String for MS SQL database

10-01-08 - by Pawel Matuszewski

This article shows how to connect from your web application to SQL Server database.