Hi Mike,
Since you might use all the data in the table, retrieving all the data from
the database and use a DataView as a filter is a good idea. Because when
you fill the dataset for the first time, all the data are dumped to the
client side. And the filter operation can be done on the client side. This
might enhance the performance.
If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| From: "Mike" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: Re: Filtering DataSet Question
| Date: Mon, 20 Oct 2003 13:50:00 -0600
| Lines: 92
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: 64.207.45.37
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:64089
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Thanks for your post. This what I am doing. When the form is loaded I go
| out and retrieve data specific to each combo box via a stored procedures
and
| then load it into a dataset for each combo box. I also retrieve all the
| data in the tables that will be specific to each user selection. Instead
of
| going back to the database to retrieve this data I have designed that each
| combo box dataset is merged to one large dataset which is then persisted
to
| an xml file. Each combo box is represented in a class heirarchy as each
is
| dervided from a base class which holds the large dataset. I decided to
| design it this way without having 8 different xml files for each dataset.
I
| have wrestled with either having one large dataset or having 8 different
| datasets. So, with that in mind is the SELECT statement the way to go?
|
| Thanks
|
| | > It kind of depends. If you want to apply one and only one filter to your
| > data and you know you are never going to want the data that's getting
| > filtered out, then using the SELECT statement is the way to go because
| > you'll have less data to transfer from your data source and less data to
| > hold in memory. However, if you want to be able to filter you data, then
| > remove the filter and see all the data, then apply a different filter,
you
| > are probably better off getting all your data and then applying the
| filters
| > thru a dataview. This will reduce the number of trips to your
datasource.
| > Although again, it depends how much data you have and how often you
think
| > you'll need to filter it.
| >
| > | > > Thanks for your post. I am still curious which way is better to
| retrieve
| > > results from a dataset. Using the select statement or a dataview?
| > >
| > > Thanks
| > >
| > > | > > >
| > > > | > > > > Hi,
| > > > >
| > > > > I have two question regarding retrieving results from a DataSet.
| > First,
| > > > > what is the best way to retrieve results from a dataset with a
| filter?
| > > >
| > > > Add a WHERE clause to your SQL statement. eg:
| > > >
| > > > SELECT * FROM myTable WHERE someField = someValue
| > > >
| > > > > Right now I am using the DataView class. I also have a question
| > > regarding
| > > > > the DataView class. Using the code below how do I cast the data
| > > returned
| > > > by
| > > > > the code below into a bool.
| > > > >
| > > > > DataView modelDataView = new
| > > > > DataView(base.componentDataSet.Tables["tblModels"]);
| > > > > modelDataView.Sort = "strCode";
| > > > > int index = modelDataView.Find(modelCode);
| > > > > v = modelDataView[index]["blnV"];
| > > > > f = modelDataView[index]["blnF"];
| > > > >
| > > > > Thanks
| > > >
| > > > assuming v is declared as a bool
| > > >
| > > > v = (bool) modelDataView[index]["blnV"];
| > > >
| > > > should work if the value was actually sorted as a boolean in the
| > database,
| > > > otherwise the value in the database is actually a string you could
| try:
| > > >
| > > > v = (modelDataView[index]["blnF"] == "TrueValue");
| > > >
| > > > where TrueValue is whatever you are interpreting as true (eg, True,
1,
| > > yes,
| > > > ....)
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|