Questions That Should Be Asked More Frequently

Q

Do I need to use a DataSet if I want to work with only a few rows of data?

A

In this situation, you can use just a DataTable object without using a DataSet. In ADO.NET 2.0, the DataTable class now lets you read and write data to and from files and streams and offers support for XML features. If you need to work with data from various DataTables, you might consider using a DataSet.

Q

I added a row to my DataTable, and when I submitted the new row to my database, I received an error that said the new row violated the primary key constraint on the table. Why didn’t I receive this error when I added the row to the DataTable?

A

ADO.NET enforces the constraints you create based on the data in your DataSet. The ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.