Using the database to build a Web page

Certify and Increase Opportunity.
Govt. Certified ASP.NET Programmer

Using the database to build a Web page

ASP.NET includes data access tools that make it easier than ever for you to design sites that allow your users to interact with databases through Web pages.
The .NET Framework includes two data providers for accessing enterprise databases: the .NET Framework Data Provider for OLE DB and the .NET Framework Data Provider for SQL Server. This section focuses on accessing SQL Server (version 7.0 or later) databases using the .NET Framework Data Provider for SQL Server, but you can adapt the code examples to other databases with only minor changes.

To access SQL databases from ASP.NET

  1. Create a database connection using the SqlConnection class.
  2. Select a set of records from the database using the SqlDataAdapter class.
  3. Fill a new DataSet using the SqlDataAdapter class.
  4. If you are selecting data from a database for non-interactive display only, it is recommended that you
    use a read-only, forward-only SqlDataReader (or OleDbDataReader for non-SQL databases) for best performance. When using a SqlDataReader, select the records using a SqlCommand query and create a SqlDataReader that is returned from the SqlCommand object’s ExecuteReader method.In some cases, such as when you want to sort or filter a set of data, you might also want to create a
    new DataView based on a DataSet for the desired table.
  5. Bind a server control, such as a DataGrid, to the DataSet, SqlDataReader, or DataView.

The .NET Framework includes three controls that make the display of large amounts of data easier: the

Repeater control, the DataList control, and the DataGrid control. These three controls all use similar data-binding procedures, as explained in the sections that follow. For additional examples of how to use these controls.

Get industry recognized certification – Contact us