48
Data Source and Data Display Controls Part 1 Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book http://www.mediafire.com/? 5kgeryodzgx

Data Source and Data Display Controls Part 1

  • Upload
    wayne

  • View
    46

  • Download
    0

Embed Size (px)

DESCRIPTION

Data Source and Data Display Controls Part 1. Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman . -ch3 illustrated book http://www.mediafire.com/? 5kgeryodzgx. Databases and Connections. - PowerPoint PPT Presentation

Citation preview

Data Source and Data Display Controls

Data Source and Data Display ControlsPart 1Reference:ASP.NET 2.0 Illustrated by Alex Homer and Dave Sussman.-ch3 illustrated book http://www.mediafire.com/?5kgeryodzgx Databases and ConnectionsMost Web sites will have some form of database behind them, whether to store a product catalog or just to manage user logins. This often requires a full installation of SQL Server on your development machine, but with ASP.NET 2.0 there is another option--SQL Server 2005 Express Edition (SSE). SSE is a cut-down version of SQL Server 2005, but has some interesting characteristics that make it especially suitable for the development environment. Two of these characteristics are automatic database attachment and user instancing.

Connection String PlacementConnection strings are typically stored in web.config, and in version 1.x that usually meant the appSettings section. In ASP.NET 2.0, there is a new connectionStrings section, which provides a similar key/value pairing.For example:

Connection String PlacementAlthough the providerName attribute isn't compulsory, connection strings won't appear in the Configure Data Source dialogs without a provider name being set.Within applications, you can access these connection strings in two ways. 1. In code, you use the ConnectionStrings property of the ConfigurationManager object. For example:SqlConnection conn = new SqlConnection(); conn.ConnectionString = ConfigurationManager.ConnectionStrings["AW"].ConnectionString;

Connection String Placement2. Within the markup of ASP.NET pages, you use an expression builder, which is a new feature of ASP.NET 2.0. Expression builders allow you to declaratively access features such as connection strings, application settings, and resources. For example, consider the following code: