[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 934
  • Last Modified:

DataAdapter VS Command

Hello,
      I am going to ask a question which looks illogical to me but I have to ask.

As you all people know that in .NET Microsoft has introduced a new concept of ADO with two new things DataAdapter and DataSet. And they called it disconnected approach.
And we have still got the other method or you can say old method which is direct access to database with command.

The point which disturbs me a lot is that should we always use DataAdapter and dataset or there are few situations when we can use it.

For example in the case of user login form which technique I need to use. DataApter or Command

Please clear my concept

With best regards fazi
0
mfazi
Asked:
mfazi
  • 2
1 Solution
 
tovvenkiCommented:
Hi,

The advantages of the dataset model are:
·      Working with multiple tables   A dataset can contain multiple tables of results, which it maintains as discrete objects. We can work with the tables individually or navigate between them as parent-child tables.
·      Manipulating data from multiple sources   The tables in a dataset can represent data from many different sources (for example, from different databases, from XML files, spreadsheets, and so on, all in the same dataset). Once the data is in the dataset, we can manipulate it and relate it in a homogeneous format as if it had come from a single source.
·      Moving data between tiers in a distributed application   By keeping data in a dataset, we can easily move it between the presentation tier, business tier, and data tier of our applications.
·      Data exchange with other applications   A dataset provides a powerful way to exchange with other components of our application and with other applications. Datasets include extensive support for features such as serializing data as XML and reading and writing XML Schemas.
·      Data binding   If we are working with forms, it is usually easier to bind controls to data in a dataset than it is to programmatically load data values into the control after executing a command.
·      Maintaining records for reuse   A dataset allows us to work with the same records repeatedly without requerying the database. Using dataset facilities, we can filter and sort records, and we can use the dataset as a source of data if we are paging.
·      Ease of programming   When we work with a dataset, we can generate a class file that represents its structure as objects (for example, a Customers table in the dataset can be accessed as the dataset.Customers object). This makes it easier, clearer, and less error-prone to program with, and is supported by Visual Studio tools such as IntelliSense, the Data Adapter Configuration wizard, and so on.

The advantage of performing database operations directly using datacommands is:
·      Extra functionality   there are some operations, such as executing DDL commands, that we can only accomplish by executing data commands.
·      More control over execution   By using commands (and a data reader, if we are reading data), we get more direct control over how and when an SQL statement or stored procedure is executed and what becomes of the results or return values.
·      Less overhead   By reading and writing directly to the database, we can bypass storing data in a dataset. Because the dataset requires memory, we can reduce some overhead in our application. This is especially true in situations where we intend to use the data only once, such as displaying search results in a Web page. In that case, creating and filling a dataset might be an unnecessary step in displaying the data.
·      Less programming in some instances   In a few instances, particularly Web applications, there is some extra programming required to save the state of a dataset. For example, in Web Forms pages, the page is recreated with each round trip; unless we add programming to save and restore a dataset, it, too, is discarded and recreated with each round trip. If we use a data reader to read directly from the database, we can avoid the extra steps required to manage the dataset.
Because of the stateless nature of Web applications and the corresponding issues associated with storing datasets, it is sometimes more practical in Web applications to work directly against the database.

I hope that this helps you.
regards,
venki
0
 
tovvenkiCommented:
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now