That's correct, those are some of the advantages of Typed datasets.
It's been a while since I've worked with Typed DataSets but IIRC, you
can simply cast the DataTable returned by the ToTable() method of the
DataView into the strongly typed DataTable of your Typed DataSet.
---
try
{
7) DataView v = dt.ALARMS.DefaultView;
8) v.Sort = "AID";
9) BASE_ANDataSet.ALARMS sortedAlarms = (BASE_ANDataSet.ALARMS)
v.ToTable();
...
}
catch(InvalidCastException ex)
{
...
}
---
My earlier post was only questioning the purpose of replacing the
original instance.
On Jan 23, 1:49 am, Nacho108 <[email protected]> wrote:
> well, if I didn't understand wrong, the advantage of a typed dataset
> is that is easier to work with, i.e. simpler sintax, more direct.
> So why would I create a typed dataset if after that I will loose this
> possibility using a dataview? dataview doesn't inheritate the typed
> thing, isn't it?
> I just created the dataview to handle the rows in some particular way
> and after that I want to have the advantage of the typed dataset
> again.
> For you to understand better, I read more than 30000 records, and
> after that I have to filter them into 100 approximately, so what's the
> point in keeping 29900 rows in the dataset?
> Also, as far as I understood, working with dataviews is better since
> the result are stored in the same dataview which I can connect to a
> datagrif, for example. Working directly with the table give as result
> a collection of rows which I have to process separatedly. Am I
> correct?
> It's possible I'm not understanding the whole concept of datatables/
> dataviews, can you shed some light on it?
>
> Anyway, for the record, Which would be the way to overwrite the whole
> table?
> Thanks!
>
> On Jan 22, 7:51 pm, Cerebrus <[email protected]> wrote:
>
>
>
> > Well, the DataTable property of the Typed dataset is (and should be,
> > by all means) ReadOnly. Why do you want to overwrite the table at
> > all ? Once you have converted it to a DataView, you can use the
> > DataView wherever you need.
>
> > On Jan 22, 9:24 pm, Nacho108 <[email protected]> wrote:
>
> > > Hi Everyone! I'm glad I'm joining the group.
>
> > > I'm new in c# programming and I have some doubts about datasets ,
> > > dataview, etc. I hope in some time I can answer and help others also.
> > > I'm reading a table within a database and then putting it within a
> > > datatable object and so far so good.
> > > The problem arises when I try to use typed datasets and using
> > > dataviews at the same time.
>
> > > 1) BASE_ANDataSet dt = new BASE_ANDataSet();
> > > 2) string sqlConnectString;
> > > 3) sqlConnectString = "Data Source=(local);User
> > > Id=sa;Password=;Initial Catalog=BASE_AN;";
> > > 4) string sqlSelect = @"SELECT * from ALARMS ";
> > > 5) SqlDataAdapter da = new SqlDataAdapter(sqlSelect,
> > > sqlConnectString);
> > > 6) da.Fill(dt);
> > > 7) DataView v = dt.ALARMS.DefaultView;
> > > 8) v.Sort = "AID";
> > > 9) dt.ALARMS = v.ToTable();
>
> > > Up to item 8 I have no problems, but then in item 9 the compiler tells
> > > me that dt.ALARMS is an read-only object.
>
> > > I tried this same code with tables and it worked just perfect.
> > > Please can someone help me with that?
>
> > > Thanks in advance !!
>
> > > Nacho- Hide quoted text -
>
> - Show quoted text -