Datatable VS Dataset

Datatable vs Dataset

It really depends on the sort of data you're bringing back. Since a DataSet is (in effect) just a collection of DataTable objects, you can return multiple distinct sets of data into a single, and therefore more manageable, object.

Performance-wise, you're more likely to get inefficiency from unoptimized queries than from the "wrong" choice of .NET construct. At least, that's been my experience.

Should I use dataset or datatable?

Use a DataTable.

A DataSet is an in-memory database while DataTable is an in-memory table.

DataSets are more complicated and heavier-weight; they can contain multiple DataTables and relations between DataTables.

What is the difference between dataview and datatable?

When you want to run a query and show the subset of data in a control, a DataView could help you. That's just one example, look at the MSDN example for DataView, that explains where you should use DataViews with DataTables...

DataTable

A datatable is an in-memory representation of a single database table. You can think of it as having columns and rows in the same way. The DataTable is a central object in the ADO.NET library. Other objects that use the DataTable include the DataSet and the DataView.

Look at MSDN The DataTable class for more details.

DataView

A dataview is a view on a datatable, a bit like a sql view. It allows you to filter and sort the rows - often for binding to a windows form control.

Additionally, a DataView can be customized to present a subset of data from the DataTable. This capability allows you to have two controls bound to the same DataTable, but showing different versions of the data. For example, one control may be bound to a DataView showing all of the rows in the table, while a second may be configured to display only the rows that have been deleted from the DataTable. The DataTable also has a DefaultView property which returns the default DataView for the table.

Look at MSDN DataView class for more details.

Difference between SqlDataReader, DataTable and DataSet and their uses

DataSet and DataTable are related, a DataSet can contain multiple tables. Both are in-memory collections like a List or Array. But a SqlDataReader isn't related since it's a forward-only stream directly to the database. So it gives you access to exactly one data-record, reader.Read will advance it to the next record.

You should read tutorials and documentation about ADO.NET and these classes. The first port of call is always MSDN. For example SqlDataReader or DataSets, DataTables, and DataViews.

List vs. DataTable vs. DataSet

What about Dictionary<char, List<operation>> ?

Difference between Arrays and DataTables?

A DataTable models a database table in memory. The type can track changes etc in order to sync with a database. The columns (dimensions) can be referenced either by index or name.

A DataSet can hold a collection of such tables and the relationships between them (referential integrity constraints).

An array doesn't do any of that.

How is a datatable different from a dataset and datareader?

a datatable represents tabulated data just like a database table. a dataset is synonymous with a database; it contains datatables, relationships etc. a datareader is a forward only row by row reader that requires an open connection. you can fill a datatable with a dataadapter. for reading look up ADO.NET.



Related Topics



Leave a reply



Submit