Re: Extracting subsets of a DataSet
- From: "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxxxxx>
- Date: Fri, 10 Apr 2009 19:20:18 +0200
Try it first with that sort on the model column commented out and see what is displayed in your datagrid.
However, try as well on Internet, I am sure that you will be disapointed.
Probably you have to go in a route where you upload the CSV to a directory first (that is not so difficult) and then start processing using your ASPNet application. However, I never did that.
Cor
"Ed" <jag_manR__EM*-0_V_E653@xxxxxxxxxxxxx> wrote in message news:eyGdrwfuJHA.1304@xxxxxxxxxxxxxxxxxxxxxxx
The code you give below is more clear, but it doesn't work for me. It fails with an unhandled exception, saying it can't find column Model. here is a snippet from my CVS file:
JOCClass,Description,YearFirst,YearLast,Model ,Series,Body,Doors,Seats,Top,EngineCyl,EngineDisp
Classics,SS I,1931,1936,SS,,Saloon,2,2,Soft,,
Classics,SS,1931,1936,SS,,,2,2,Soft,,
Classics,SS Saloon 1.5,1936,1940,SS,,Saloon,2,4,Soft,,1.5
Classics,SS Saloon 2.5,1935,1940,SS,,Saloon,2,4,Hard,6,2.5
Classics,SS Saloon 3.5,1937,1939,SS,,Saloon,2,4,Hard fixed,6,3.5
Classics,SS Tourer 2.5,1935,1937,SS,,Open tourer,2,4,Soft,6,2.5
Regarding the example I was following, I'm not sure where I got it. I can't find it in the Visual Studio .NET I'm using (2002 version, BTW), so it might have been out of an online source.
Regarding the application I am making, it is a Web Form, not a Windows Form. Or, at least that is my intention. I am running it on my local Windows XP Pro machine under IIS. However, at some point I intend to upload it to my hosting sirvice provider, IVCHosting.com. I have been laboring under the assumption that this is what one is supposed to do: develop and test locally, then deploy to a real Web server to expose it to the Internet. I'd like to believe that the application would behave the same in both places as long as the host has the services I am using. ut from what you say here, I guess I ought to try deployment right away to see if there is basis for my optimism.
Thanks for you patience, Cor.
Ed
"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxxxxx> wrote in message news:uNGCa7YuJHA.1300@xxxxxxxxxxxxxxxxxxxxxxxEd,
I don't know where you got the sample but this should be enough
\\\
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
' subset of rows in which Top = Soft
Dim dv As new DataView(ds.Tables(0))' try to avoid names as view as those are often keywords
dv.RowFilter = "Top = 'Soft'"
dv.Sort = "Model DESC"
dgSoftTops.DataSource = dv
dgSoftTops.DataBind()
////
However, you are making your application now as a kind of windowsform application. As I wrote before, are you normally not able to get a csv file from a client computer using ASPNET. It is now working in the test situation because it is on your own computer which is also the server.
It can be that this is the way you want it, but then it is probably easier and more elegant to simply make a windowsform application (and you can use your csv files then).
Cor
"Ed" <jag_manR__EM*-0_V_E653@xxxxxxxxxxxxx> wrote in message news:unzFyiYuJHA.1504@xxxxxxxxxxxxxxxxxxxxxxxNo, that's not what I was trying to do. I was trying to use DataView as you suggested. I was using an example I found in the documentation, but from what you say here I am way off. However, I have abandon the DataView idea because what I have read about DataView does not seem to be what I want. As i understand it, DataView's principal usage is in situations where the dataset is subject to change, and the various DataViews are to change accordingly. I don't need that because in any single session of the Web app I am trying to create the data does not change. I am instead pursing the approach suggested by Armin. It works quite nicely for a single constrained descriptor. My problem at the moment is to aply multiple constrained descriptors so the user can quickly narrow down his region of search. Allow me to elaborate.
My view of my problem is as follows:
I have a CVS file that is a set of rows with headers. My goal is to display only, not modify, a subset of those rows based on user input. For example, if the user says his car has a soft top, and all other descriptors are not specified, I want to display all rows for which the column headed "Top" has a value of "Soft." If he also says it's Model designition is "E-Type" it should display only E-types with soft tops. Right now, my thinking is to do a series of "removals" based on single descriptor constraints. Keep in mind that I am NOT talking about removal from the original data, bou only from the internal data structure in which it was read. So after removing all those that are not Soft Top, I then remove all those that are not E-Types. the remainder are only hard top E-Types. (BTW, ar eyou a Jag fan?)
I am also thinking about another strategy, namely doing only a single Select, based on a Select string that is constructed, e.g.,
strSelect = "Top = 'Soft' And Model = 'E-Type'"
Dim drSelection() As DataRow = dtAllModels.Select(strSelect)
If that does works it accomplishes the task at one fell swoop. What do you think?
The problem I have with Scotts suggestion is I think it reflects a misunderstanding of what I am trying to do, certainly due to my poor explanations and lack of familiarity of the terminology used here. But perhaps I don't know wht he means when he suggests going entirly to a real database environment. If he means switching to a real database for my main project, of which the Web app is just a adjunct, that's not likely to happen. The main project is a Windows based membership records system to be used by a succession of club members with varying degrees oc computer skills. Excel has the advantage of being widely used by lay people. If I switched even to Access the club likely would be unable to find anyone to do the job. So, it seems entirely reasonable to simply export a CVS file from Excel for use as a read-only input for this little Web app.
Thanks for listening, and for your help. I feel I am making progress.
Ed
"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxxxxx> wrote in message news:%23T9wMcXuJHA.4324@xxxxxxxxxxxxxxxxxxxxxxxEd,
You are sure you only want the modified rows?
I doubt that
Cor
"Ed" <jag_manR__EM*-0_V_E653@xxxxxxxxxxxxx> wrote in message news:eAoeHUVuJHA.4444@xxxxxxxxxxxxxxxxxxxxxxxCor,
I'm trying to use the DataView, but must not understand something. Here is a snip from my code:
[.... the following code is preceded by code that loads ds.Table(0). The full table is successfully displayed in DataGrid1 ...]
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
' subset of rows in which Top = Soft
Dim view As DataView = New DataView()
With view
.Table = ds.Tables(0)
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = "Top = 'Soft'"
.RowStateFilter = DataViewRowState.ModifiedCurrent
'.Sort = "Model DESC"
End With
' Bind to a DataGrid control
dgSoftTops.DataSource = view
dgSoftTops.DataBind()
When this gets executed the dgSoftTops DataGrid shows with only the header row. IOW, the filtering seems to exclude all rows, even though there are many rows in which Soft ocurs in the Top column.
Can you see what I'm doing wrong here?
Thanks,
Ed
"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxxxxx> wrote in message news:%2322OWZNuJHA.4980@xxxxxxxxxxxxxxxxxxxxxxxEd,
That is not so difficult, there are two possibilities, in your situation I would start to try the Dataview (which is in a datatable as the defaultview) rowfilter
http://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter.aspx
Cor
"Ed" <jag_manR__EM*-0_V_E653@xxxxxxxxxxxxx> wrote in message news:uAfavPKuJHA.4364@xxxxxxxxxxxxxxxxxxxxxxxNow that I know how to read my data from a CVS file into a DataSet, I need to know how to work with it. How do I create another DataSet that has only those rows from the full table that have a specified value of certain attributes?
For example, suppose my full table looks like this:
JOC Class Description Year first Year last Model Series Body style Doors Seats Top Engine cyl. Engine disp.
Classics SS I 1931 1936 SS Saloon 2 2 Soft
Classics SS 1931 1936 SS 2 2 Soft
Classics SS Saloon 1.5 1936 1940 SS Saloon 2 4 Soft 1.5
Classics SS Saloon 2.5 1935 1940 SS Saloon 2 4 Hard 6 2.5
Classics SS Saloon 3.5 1937 1939 SS Saloon 2 4 Hard 6 3.5
Classics SS Tourer 2.5 1935 1937 SS Open tourer 2 4 Soft 6 2.5
Classics SS 100 2.5 1936 1940 SS Roadster 2 2 Soft 6 2.5
Classics SS 100 3.5 1937 1940 SS Roadster 2 2 Soft 6 3.5
Classics SS DHC 1.5 1937 1940 SS Drop head coupe 2 2 Soft 6 1.5
Classics SS DHC 2.5 1937 1940 SS Drop head coupe 2 2 Soft 6 2.5
Classics SS DHC 3.5 1937 1939 SS Drop head coupe 2 2 Soft 6 3.5
Limo DS 420 Limo 1968 1992 DS Limo 4 4 Hard 6 4.2
XK Sports cars XK 120 roadster 1949 1952 XK Roadster 2 2 Soft 6 3.4
XK Sports cars XK 120 OTS 1949 1952 XK Drop head coupe 2 2 Soft 6 3.4
XK Sports cars XK 120 DHC 1949 1952 XK Convtible 2 2 Hard 6 3.4
XK Sports cars XK 120 FHC 1949 1952 XK Fixed head coupe 2 2 Hard 6 3.4
E-Type E-Type OTS Ser. 1 3.8L 1961 1961 E-Type 1 Open two seater 2 2 Soft 6 3.8
How do I create a new DataSet that has only the rows that have Model = XK and Top = Hard
I realize this is revealing my ignorance of relational databases, but mayben someone can get me going in the right direction.
Thanks.
Ed
.
- References:
- Extracting subsets of a DataSet
- From: Ed
- Re: Extracting subsets of a DataSet
- From: Cor Ligthert[MVP]
- Re: Extracting subsets of a DataSet
- From: Ed
- Re: Extracting subsets of a DataSet
- From: Cor Ligthert[MVP]
- Re: Extracting subsets of a DataSet
- From: Ed
- Re: Extracting subsets of a DataSet
- From: Cor Ligthert[MVP]
- Re: Extracting subsets of a DataSet
- From: Ed
- Extracting subsets of a DataSet
- Prev by Date: Re: Datagrid...
- Next by Date: Re: Datagrid...
- Previous by thread: Re: Extracting subsets of a DataSet
- Next by thread: Gridview Combo Box Problem
- Index(es):
Relevant Pages
|