Updating typed datasets

When we as developers are learning new techniques, examples can be our own worst enemies. In this article we're going to take a look at what it means to strongly-type objects from your database, and why despite the lack of examples, you will almost always want to do so in your applications.Tutorials are designed to be easy to understand, but at the same time they often reinforce lazy, inefficient, and even dangerous coding practices. Specifically, we will see how to create and use strongly-typed Data Sets in Visual Studio 2005.

I can't find anything in my books, or MSDN about this subject... I'm used to doing this sort of thing for databases through a sql Data Adapter, and using "update" to modify the datasource, but I don't get how to have an adapter to the XML file. -D psudo - code of what I'm wanting to do: dim ds as new Entries XML("the XMLFile.xml") dim dr as new Entries.entry Row dr.item1 = "blah" dr. I then want to add a new row to the dataset and save it back to disk.

Item2 = "blah" add(dr) XML("the XMLFile.xml") Hi Big, Data Row is part of a Data Table and not of a Data Set. Each row in the dataset is defined as an "entry", so I have a entry Data Row member of my Entries dataset.

Hi all, I have an xml file that I load into a strongly typed dataset via the Read XML method of the dataset.

I then want to add a new row to the dataset and save it back to disk.

All else being equal, you should never use a generic object when you can use a more specific one. However, just as having quality relationships takes time and energy, so also strongly typing your objects takes extra effort.

The good news is that the extra time spent here is worth it and saves exponentially more time bug-hunting in the future.

If you're wise, a thoughtful list will save you from unnecessarily painful emotional trauma.

You may find, for example, that a serious relationship with an alcoholic is a recipe for instability and unpredictability.

As your friend, I must implore you, "Have some standards! " Just as neglecting to screen who you date can cause relational problems in the future, being loose with your objects can create errors in your code.

Tags: , ,