Database and Asp.Net

|
The technologies that helps retrieving the data from
database have been on a progressive trend, and been gone through
ODBC, DAO, RDO, ADO etc. The asp net uses ADO.Net and without
ADO..Net.
The technologies those do not uses ADO.Net are the followings
- SqlDataSource control : It is a rich control and do
not need ADO.Net, rather ADO.Net uses this control underneath ,
and SqlDatasource support any database that has AD.Net provider.
- GridView uses SqlDataSource control.
- SqlDataSource control mostly relies on ObjectDadaSource
( useually created with a Class and placed in App_Data
- LINQ to SQL
- Profiles
|
Ref Mathews APress 9781


|

As you can see in Figure 8-3, each item in the DataSet.Tables
collection is a DataTable. The
DataTable contains its own collections—the Columns collection of
DataColumn objects (which
describe the name and data type of each field) and the Rows
collection of DataRow objects
(which contain the actual data in each record).
Each record in a DataTable is represented by a DataRow object.
Each DataRow object represents
a single record in a table that has been retrieved from the data
source. The DataRow is the
container for the actual field values. You can access them by field
name, as in myRow["FieldName"].
Always remember that the data in the data source is not touched at
all when you work with the
DataSet objects. Instead, all the changes are made locally to the
DataSet in memory. The DataSet
never retains any type of connection to a data source.
The DataSet also has methods that can write and read XML data and
schemas and has methods
you can use to quickly clear and duplicate data. Table 8-1 outlines
these methods. You’ll learn more
about XML in Chapter 14.

Connection String


Command Class


|
Disconnected data
With ADO.Net, the data you retrieve is not connected with the
data source or database. Any change in the DataSet that copied the
data from the database or data source, can safely be manipulated,
and at the end, if it is required, you can sync with the original
data source in a single batch operation. (page 311 Mathew 0781 )
DataSet is easier to use than a DataReader include the following:
- When you need a convenient package to send the data to
another component (for example, if you’re sharing information
with other components or distributing it to clients through a
webservice).
- When you need a convenient file format to serialize the data
to disk (the DataSet includes built-in functionality that allows
you to save it to an XML file).
- When you want to navigate backward and forward through a
large amount of data. Forexample, you could use a DataSet to
support a paged list control that shows a subset of information
at a time.
- The DataReader, on the other hand, can move in only one
direction:forward.
- When you want to navigate among several different tables.
The DataSet can store all these tables, and information about
the relations between them, thereby allowing you to create easy
master-detail pages without needing to query the database more
than once.
- When you want to use data binding with user interface
controls. You can use a DataReader for data binding, but because
the DataReader is a forward-only cursor, you can’t bind your
data to multiple controls. You also won’t have the ability to
apply custom sorting and filtering criteria, like you can with
the DataSet.
- When you want to manipulate the data as XML.
- When you want to provide batch updates. For example, you
might create a web service that allows a client to download a
DataTable full of rows, make multiple changes, and then resubmit
it later. At that point, the web service can apply all the
changes in a single operation (assuming no conflicts occur).
|
The DataSet also supports( mathew page 313)
data binding, which allows you to display your information in
advanced data controls such as the
GridView. For that reason, most web applications retrieve data into
the DataSet but perform direct
updates using straightforward commands.
Using the DataSet, an application on the user’s laptop can store
disconnected data locally and serialize it to an
XML file. This allows the sales associate to build new orders using
the cached data, even when no
Internet connection is available. The new data can be submitted
later when the user reconnects to
the system.
|

|
Data Adapter Class


|
Filling A dataSet

string connectionString =
WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
string sql = "SELECT * FROM Employees";

|
|


|
|
|
|
|
|
|
|
|