none
dataset vs sql queries

    Question

  • I have recently migrated from vb6 to c#.net. Undoubtedly the power of .net framework is endless which practically offered me so many features that i don't want to switch back to vb6.
    Recently i m creating a small software for local market. In this project I have created a database framework that would return dataset, datareader and execute non query without much effort. 
    Here i've been using datareader to get data from database and populate them into controls when needed. And i use insert or update query to update records into database. My question is am i utilizing the full potential of ado.net. I haven't used dataset in any way. How practical  it is to use insert or update/delete query in .net  instead of using dataset. or do i need to start using datasets immediately so as to utilize the power of ado.net.

    Plz guide me through this.

    Tuesday, December 29, 2009 1:24 PM

Answers

  • Hi Ishwor,

    SQL queries are required in any case; with or without DataSet. The difference between DataSet and DataReader is the following:

    DataSet is set of tables and realtions among the tables. DataReader is an object, allowing you to read data from database. To use a DataSet you need to use DataAdapter/TableAdapter. DataAdapter/TableAdapter is an object with 4 SqlCommands (Delete, Insert, Select, Update). These commands are used to select values from database or to update the database upon the RowState in each record. Behind the scenes each command executes it's own DataReader/DataWriter.

    Using a DataReader will lead you to create your own entities. DataSet on the other side can be created from designer. Designer allows you to create tables, relations, contraints,... Drag and drop from Server Explorer might be another benefit. With DataAdpater you can create a typed DataSet upon the queries. If you're application requires import/export, you'll have to write this functionality on your own when using custom entities. With DataSet this ain't a problem, allowing you to import/export data into XML. It can also be bound to DataGridView or any other similar control. DataSet also supports one level of history, allowing you to revert to previous version of each row.

    I also suggest reading this documentation:
    http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx

    If you feel, more should be told about DataSet, just say.


    Regards,
    Danijel

    Blog, Twitter
    Wednesday, December 30, 2009 11:48 AM