ASP.NET - SPLessons

ASP.NET Database Connection

Home > Lesson > Chapter 21
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

ASP.NET Database Connection

ASP.NET Database Connection

shape Description

In ASP.NET Database Connection is one of the most important part. In case of web applications, lot of data are stored into database. To access that huge amount of data database connection is compulsory for any web application. Here, let's introduce ADO.NET for this operation. ADO.NET is also a part of .NET framework. ADO.NET is a set of classes for providing access to data in .NET framework. System.Data is the base namespace for ADO.NET API. System.Data.OleDb and System.Data.SqlClient, provide set of classes which interact with database.

Connected Data Access Architecture

shape Description

Here, the web application makes the connection to the database first and then interacts with the SQL queries using the same request. Web application stays connected to the database even if it is not doing any database operation.

Disconnected Data Access Architecture

shape Description

Disconnected model makes the application execute the query, then retrieve the results and store it for processing. In this model, web application minimizes time to connect to database. Using one database object, data adapter and a connection object it interacts with database. The Disconnected Data Access Architecture is more flexible and powerful than the Connected Data Access Architecture. [html]<connectionStrings> <add name="spConnectionString" connectionString="server=localhost;database=spDb;uid=spUserId;password=spPassword;" /> </connectionStrings>[/html] The above modification is needed in web.config file to connect to database.