.status-msg-wrap { display: none; }
Database SQL Oracle MySql
Sunday, March 23, 2014
no image

ADO.NET Components

Database Classes
Access and update databases
Uses “Managed Provider” to connect to DB
Data Classes
Hold data in-memory, disconnected from database
User defined structure. Does not have to map to DB.
DataSet” is the key class

Database Classes
Execute database commands and make results available.
Connection: a database connection
Command: what to execute, generally SQL
DataReader: Read-only, forward-only cursor.
DataAdapter: Connects a DataSet to the database and can resolve changes back to DB
CommandAdaptor: Automatically generates Insert/Update/Delete commands from a Select command (expensive!)
Connections are always made thru “Managed Providers”
Essentially the next version of OLEDB
Native, .net managed data-access components
Remember: Managed means .net handles memory management, security etc.
Only two Managed Providers at time of writing:
Microsoft SQL Server, included with .net
Microsoft OLEDB, included with .net
Enables developers to work with existing OLEDB drivers until managed versions available.

Data classes: DataSet
Hold a disconnected, in-memory version of the data
Designed to hold >=1 table of data at a time
improvement over ADO where a RecordSet could only hold a single table.
Can model relationships between those tables and enforce them on the client
Save as XML with schema
Can design visually in Visual Studio or use DataSet class directly – see next slide for details
May or may not be direct representation of database
Note: By default, DataAdapter can only automatically insert/update/delete direct representations of database
Benefits of ADO.NET

Benefits of ADO.NET

Increased Interoperability
Can save and load from XML
XML is the way to exchange data between business
any programming language use it.
Increased Scalability
Targets distributed, disconnected web scenarios
Built in support for disconnected record sets
Enables integration of data from multiple heterogeneous data sources

Automatic Connection Pooling (COM+ based)


What is ADO.NET

What is ADO.NET

Acronym for ActiveX Data Objects
ADO.NET is the successor to Microsoft’s ADO technology
Both provided consistent, high-performance access to data
ADO.NET more focused on needs of today’s eCommerce environment

A data access framework and API
Saturday, March 22, 2014
What’s in the .NET Framework?

What’s in the .NET Framework?

Microsoft Intermediate Language (MSIL):
Specification for a platform independent, low-level, stack-based assembly-like language
Common Language Runtime (CLR):
A common runtime for all .NET applications, compiles and executes MSIL
Class libraries:
Common functionality that can be used by all languages
Includes Windows Forms for GUI development
Language compilers:
C#, C++, VB…
Distributed computing:
Networking using sockets, Remoting, Web Services and Applications using ASP.NET
Thursday, March 20, 2014
no image

The Data Access Layer

The data access layer is the simplest layer of the traditional three-tiered architecture.
Simply put, the data access layer calls stored procedures that reside in the database or executes dynamic
SQL against the database. In prior versions of the .NET Framework, as the developer you were responsible for making sure that you knew which type of ADO.NET object should execute a stored procedure
and what type of object should be passed back to the business layer. The debate about which object to
pass back to the business layer is always heated, but the .NET Framework has given us a tool that could
calm those debates.
ASP.NET MVC PAGE LIFE CYCLE

ASP.NET MVC PAGE LIFE CYCLE


What is ASP.NET MVC: ASP.NET MVC is a part of the ASP.NET Web application framework. It is one of the two different programming models you can use to create ASP.NET Web applications, the other being ASP.NET Web Forms.

An MVC Application is designed and implemented using the following three attributes




•      Model: The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic.
•    View: The view encapsulates the presentation of the application, and in ASP.NET this is
typically the HTML markup.
•      Controller: The controller contains the control‐flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.

Page Life Cycle of ASP.NET MVC

Requests to an ASP.NET MVC‐based Web application first pass through the UrlRoutingModule object, which is an HTTP module. This module parses the request and performs route selection. The UrlRoutingModule object selects the first route object that matches the current request. (A route object is a class that implements RouteBase, and is typically an instance of the Route class.) If no routes match, the UrlRoutingModule object does nothing and lets the request fall back          to          the          regular          ASP.NET          or          IIS          request          processing. From  the  selected  Route  object,  the  UrlRoutingModulobject  obtains  the  IRouteHandler object that is associated with the Route object. Typically, in an MVC application, this will be an instance of MvcRouteHandler. The IRouteHandler instance creates an IHttpHandler object and


passes it the IHttpContext object. By default, the IHttpHandler instance for MVC is the MvcHandler object. The MvcHandler object then selects the controller that will ultimately handle the request.

The module and handler are the entry points to the ASP.NET MVC framework. They perform the following actions:

•    Select the appropriate controller in an MVC Web application.
•    Obtain a specific controller instance.
•    Call the controller's Execute method.

The following table lists the stages of execution for an MVC Web project.

Stage
Details
Receive      first
request for the application
In the Global.asax file, Route objects are added to the RouteTable object.
Perform
routing
The UrlRoutingModule module uses the first matching Route object in the
RouteTable collection to create the RouteData object, which it then uses to create a RequestContext (IHttpContext) object.
Create       MVC
request handler
The MvcRouteHandler object creates an instance of the MvcHandler class
and passes it the RequestContext instance.
Create controller
The MvcHandler object uses the RequestContext instance to identify the IControllerFactory object (typically an instance of the DefaultControllerFactory class) to create the controller instance with.
Execute
controller
The MvcHandler instance calls the controller's Execute method.
Invoke action
Most controllers inherit from the Controller base class. For controllers that do
so, the ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and then calls that method.
Execute result
A typical action method might receive user input, prepare the appropriate
response data, and then execute the result by returning a result type. The built‐in result types that can be executed include the following: ViewResult (which renders a view and is the most‐often used result type), RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, and EmptyResult.




Figure 1: ASP.NET MVC Request



A URL Does Not Equal a Page


When  you  build  traditional ASP.NET Web  Forms application or  an  Active  ServePages  application, there is a one‐to‐one correspondence between a URL and a page. If you request a page named SomePage.aspx from the server, then there had better be a page on disk named SomePage.aspx. If the SomePage.aspx file does not exist, you get an ugly 404 Page Not Found error. When building an ASP.NET MVC application, in contrast, there is no correspondence between the URL that you type into your browser’s address bar and the files that you find in your application. In an ASP.NET MVC application, a URL corresponds to a controller action instead of a page on disk. In a traditional ASP.NET or ASP application, browser requests are mapped to pages. In an ASP.NET MVC application, in contrast, browser requests are mapped to controller actions. An ASP.NET Web Forms application is content‐centric. An ASP.NET MVC application, in contrast, is application logic centric.
Copyright © 2014 ASP.NET & C# & IIS & Crystal Report & Database & ADO.NET All Right Reserved
Designed by ASP.NET Tuts