Running web applications with databases
Web applications are basically applications that rely on the active work with data.
The interaction of web-applications with databases (databases) is performed, as well as windows-applications, using ADO.Net technology  and other technologies, such as Linq-to-SQL and Entity Framework. Working with ADO.Net can be performed both in a mode with connection support (working with data providers - Connection classes, Command and DataReader classes), and in disconnected mode (DataAdapter, DataSet, DataTable, DataView, etc.) classes. Using such classes, you can perform database queries and retrieve data fetches (for example, DataReader or DataTable class objects), which will then be used in the code in the required way (for output in the web form).
The main means of interaction between web applications and data are as follows:
1) Executable expressions of the form & lt;% # [expression]% & gt; and & lt;% $ [expression]% & gt ;;
2) data sources and binding components with data sources;
3) linking server-side ECs to data sources;
4) templates for describing server-side ECs using the executable expressions & lt;% # Eval (...)% & gt;.
In a web application, different .NET classes can be used as data sources, and only those that organize interaction with the database can be used. In ASP.NET, any object that supports the IEnumerable interface can be associated with server-side ECUs. The Enumerable interface defines the minimum API that is required to enumerate the content of the data source. However, many related objects actually implement more advanced versions of IE-numerable, interfaces such as ICollection and IList . In particular, server-based web-based ECUs can be associated with objects of the following classes:
• Collection objects - including Dictionary, Hashtable and Array;
• objects of the DataReader class of the ADO.NET providers;
• ADO.NET container class objects, such as DataSet, DataTable, and DataView;
• any objects that are obtained by processing a LINQ query that support the IQueryable interface.
In addition to the objects of the listed classes, the data sources can be special components of binding to data sources (data source components). The Data Source Binding Component (CID) is a server control that is designed to interact with data-bound controls and to hide the complexity of the software binding of the EI to the data source. Such components not only provide data for server ECUs, but they also support the execution by these ECs of other common data operations, such as adding new data, deleting, sorting and updating. Each CSID is a wrapper for some data provider - relational databases, XML documents, special object models, or developer-created classes. The support of the classes created by the developer means that it is possible to directly link the EE to existing classes, for example, with business logic level classes or data access classes.
All binding components with data sources support retrieving data using the Select method. This method returns an object that implements the Enumerable interface.
The types of main data source components are described in Table. 4.6.
Basic components for linking to data sources
Provides a connection to the Microsoft Access database. Inherits from the SqlDataSource component, but works with MDB files and uses the Jet 4.0 OLE DB data provider to connect to the database
Enables the use of Entity Framework query processing results
Allows you to use the results of any provider that supports LINQ requests, including LINQ-to-SQL. This component allows you to set the data context, the table name, the display parameters of the table fields to class properties and the where clause conditions
Allows you to communicate with the developers of .Net-classes of business logic that return data. It is assumed that these classes correspond to a special design pattern and include, for example, a constructor without parameters and methods that work in a certain way
Provides a connection to an ADO.NET data provider that returns SQL data, including data sources that are accessible using OLE DB and ODBC technologies. The provider name and connection string are specified using component properties
Allows you to contact any provider that provides information about the site map. By default, the provider provides data to the site map contained in the XML file stored in the root folder of the web application
Allows you to communicate with XML files and strings files and strings with or without schema information
To configure the SqlDataSource component, you can use the wizard that is launched when you click on the "Configure Data Source" link; (Figure 4.15).
The first step of configuring the SqlDataSource element is to determine the connection to the database. If there is already a connection to the data source, you can simply select it from the list, otherwise you can create and configure a new connection to the database by clicking the New Connection button.
In the second step , the wizard suggests saving the generated connection string to the database in the web.config file. If necessary, you can opt out and change the name of the variable containing the connection string.
Fig. 4.15. Using the Data Source Control
The third step of the wizard allows you to define the database queries used by SqlDataSource to perform operations on the data. In particular, it is suggested to select a table and generate a query for a sample of its data. You can also define your own select, add, delete, and update data, or specify the stored procedure you are using.
The wizard can also generate standard queries used to add, delete, and update values in a linked data source if the fields that are primary keys of the table are selected. You can use the Advanced button to build these queries. This will open a window in which you can set two properties. Link Generate INSERT, UPDATE, and DELETE statements Specifies the mode of creating corresponding queries.
The fourth step of the wizard allows you to test the generated query and, after clicking the Finish button, complete the configuration of the data source control.
As a result of these operations, a description of the binding component with the data source will be added to the description of the form template, for example,
& lt; asp: SqlDataSource ID-'SqlDataSource1! runat- server
ConnectionString = & lt;% $ ConnectionStrings: Northwind% & gt;
SelectCommand-SELECT [EmployeelD], [LastName], [FirstName], [Address],
[City], [PostalCode] FROM [Employees] "
& lt;/asp: SqlDataSource & gt;
After describing such a component, you can associate the controls with it. To do this, its DataSourcelD property must be set to the name of the SqlDataSource object.
Note that each binding component with a data source can be used to connect to only one database table. If you need to extract or update information from multiple tables independently in a web application, you need to use several such components.
Also We Can Offer!
- Argumentative essay
- Best college essays
- Buy custom essays online
- Buy essay online
- Cheap essay
- Cheap essay writing service
- Cheap writing service
- College essay
- College essay introduction
- College essay writing service
- Compare and contrast essay
- Custom essay
- Custom essay writing service
- Custom essays writing services
- Death penalty essay
- Do my essay
- Essay about love
- Essay about yourself
- Essay help
- Essay writing help
- Essay writing service reviews
- Essays online
- Fast food essay
- George orwell essays
- Human rights essay
- Narrative essay
- Pay to write essay
- Personal essay for college
- Personal narrative essay
- Persuasive writing
- Write my essay
- Write my essay for me cheap
- Writing a scholarship essay