O'Reilly logo

ADO.NET Cookbook by Bill Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Copying and Transferring Data

Introduction

This chapter focuses on copying data between ADO.NET classes and between ADO and ADO.NET classes, serializing and deserializing data, and encrypting data and login credentials to build secure applications.

Copying rows from one DataTable to another and copying tables from one DataSet to another are operations performed frequently in data-centric applications. Recipe 5.1 and Recipe 5.2 show different ways to copy data and discuss the advantages, limitations, and disadvantages of the different approaches.

The DataReader provides connected forward-only, read-only access to a data stream while the DataSet provides disconnected access to data stored as an in-memory relational database. There is no built-in method to convert a DataReader to a DataSet, so Recipe 5.3 shows how it’s done.

In addition, this chapter covers:

Serializing and deserializing data

Serialization allows data conversion to a format that can be persisted or transported. The .NET framework supports serialization and deserialization with the System.Runtime.Serialization namespace. Support for binary, XML, and SOAP formats is built in and serialization can easily be customized if required. Recipe 5.4 and Recipe 5.5 show how to serialize and deserialize data.

As well as copying data, ADO.NET supports merging disconnected data in DataTable or DataSet objects into each other. Recipe 5.6 shows how merging works and how to use the arguments that control the merge operation.

Security ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required