Datasets

J

JJ

Hi All,

I am writing a Win App in C# that has a data class for
my mid business component. I call it to fetch data for me
and return back a dataset to my Win app. So in order to
read my dataset that's returned I need to open up a
DataAdapter again and attach a Reader. If I want to
access the data in the dataset, Correct? Does this sound
like a logical way for the design of my Win App? Any
other ways I should look at? patterns?

Thanks,

JJ
 
G

Guogang

Access table: DataSet.Tables[0]
Access a row: DataSet.Tables[0].Rows[0]["LastName"]
 
J

Jon Skeet [C# MVP]

JJ said:
I am writing a Win App in C# that has a data class for
my mid business component. I call it to fetch data for me
and return back a dataset to my Win app. So in order to
read my dataset that's returned I need to open up a
DataAdapter again and attach a Reader. If I want to
access the data in the dataset, Correct? Does this sound
like a logical way for the design of my Win App? Any
other ways I should look at? patterns?

There are two possibilities here:

1) Write a very simple implementation of IDataAdapter which doesn't
inherit from DataAdapter or DbDataAdapter, and just implements
Fill/Update etc appropriately, with no need for a DataReader.

2) Write a more complete implementation of all the data-related
classes, probably inheriting from DbDataAdapter. Here you would
implement your own DataReader and DbDataAdapter would fill the DataSet
for you automatically. You need to write a lot more classes though.

In the past couple of days I've done both in a very limited way (i.e.
with entirely mock objects which don't do a lot, just filling in the
methods I'm interested in) and it's not too bad, but the documentation
isn't terribly good, unfortunately.

Of course, you don't *have* to do any of this - you could just write
your own class which didn't use a DataAdapter at all, and just returned
a DataSet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top