13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 10-10: The user <strong>in</strong>terface of the application when the batch update fails on a row.Notice the custom error message on the row <strong>in</strong> error. This message is obta<strong>in</strong>ed us<strong>in</strong>gthe follow<strong>in</strong>g code:// Select all the rows <strong>in</strong> error after the batch update<strong>for</strong>each(DataRow row <strong>in</strong>m_dataSet.Tables["Employees"].GetErrors()){str<strong>in</strong>g msg = row.RowState.ToStr<strong>in</strong>g() + "row. Failed.";row.RowError = msg;}Updat<strong>in</strong>g conflicts and reconcil<strong>in</strong>g tables after a batch update procedure can beexpensive. Sometimes, it might be even more costly than work<strong>in</strong>g connected. Choos<strong>in</strong>gthe right application perspective is a delicate task with quite a simple guidel<strong>in</strong>e: go <strong>for</strong>disconnection if you have a low degree of data contention and your tables aren'tupdated frequently with highly volatile data.ConclusionIf you've recently programmed data-driven applications, disconnected programm<strong>in</strong>g isnoth<strong>in</strong>g new <strong>for</strong> you. Disconnected scenarios are key <strong>in</strong> the era of the Internet, as theylet you ga<strong>in</strong> <strong>in</strong> scalability and mobility, br<strong>in</strong>g<strong>in</strong>g simplification to the software and to theuser. For disconnected applications, effective local copies of the data are more thanvital—they're absolutely mandatory.For .<strong>NET</strong> Framework applications, the DataSet object is the ideal candidate to take theposition of the client-side data conta<strong>in</strong>er <strong>in</strong> disconnected, <strong>in</strong>termittent applications. Inthis chapter and <strong>in</strong> Chapter 9, we analyzed various options <strong>for</strong> serializ<strong>in</strong>g the contentsof a DataSet object to output streams. In this chapter <strong>in</strong> particular, we analyzed astateful way to persist the DataSet contents.In general, there are two different angles from which you should look at the DataSetobject's serialization. One is the physical layout of the data when stored to disk; theother is the statefulness of the <strong>for</strong>mat. Normally, a DataSet object serializes itself us<strong>in</strong>ga couple of <strong>XML</strong> blocks—schema and data. This data can then be saved as is to a textor SOAP output stream or saved to a more compact b<strong>in</strong>ary stream. In this case,385

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!