473,288 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Dataset filtering problem

Hi,

I have a problem that might be easy to solve(possibly, I've just overlooked
an easy solution). Here we go:

I have a dataset with 2 datatables in it. Now, I need to do the following:

if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2") then

txtResult.text = ds.table(1).rows(0).item("col3")

end if

The problem is, that possible match exists in the database, but not
nessasarily at Rows(0). It could be at different index. But how to actually
get to the correct index??

I looked into the database, and in my case first possible match is at index
Row(1) so the correct version'd be like this:

if ds.table(0).rows(1).item("col1") = ds.table(1).rows(1).item("col2") then

txtResult.text = ds.table(1).rows(1).item("col3")

end if

But of course, there is no way to know in advance, what index to use, so I'm
lost a bit.

Basically, I have a couple of ways of doing it. I could use Select or Find
methods of datatable object to apply filtering on the datatables. But, the
problem is that filtering needs to be applied on 2 different tables of the
dataset, but I know how to do it for 1 datatable only. I need to merge 2
datatables into dataview and apply a filter. But how to do it? Anyway, if
anyone has any ideas, so please share it with me. Thanks a lot in advance,

--Alex


Jul 21 '05 #1
3 3123
Hi Alex,

You're making it more difficult than it is.

1. Set up a dataview for one of the tables.
2. do a for each loop of the other table and search the dataview for the
value - if found, etc.
3. after you'r done, you should have found each match, and the view's find
method will return the appropriate index.

HTH,

Bernie Yaeger

"Alex Ayzin" <Al********@verizon.net> wrote in message
news:eK*************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go:

I have a dataset with 2 datatables in it. Now, I need to do the following:

if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2") then
txtResult.text = ds.table(1).rows(0).item("col3")

end if

The problem is, that possible match exists in the database, but not
nessasarily at Rows(0). It could be at different index. But how to actually get to the correct index??

I looked into the database, and in my case first possible match is at index Row(1) so the correct version'd be like this:

if ds.table(0).rows(1).item("col1") = ds.table(1).rows(1).item("col2") then
txtResult.text = ds.table(1).rows(1).item("col3")

end if

But of course, there is no way to know in advance, what index to use, so I'm lost a bit.

Basically, I have a couple of ways of doing it. I could use Select or Find
methods of datatable object to apply filtering on the datatables. But, the
problem is that filtering needs to be applied on 2 different tables of the
dataset, but I know how to do it for 1 datatable only. I need to merge 2
datatables into dataview and apply a filter. But how to do it? Anyway, if
anyone has any ideas, so please share it with me. Thanks a lot in advance,

--Alex


Jul 21 '05 #2
Thank you for you reply, Bernie.

I just don't see how I'd actually get a match using this technique.
Could you elaborate a little bit?
Actually, I simply don't understand, how there is no filtering based on
multiple - datatables criterias.

Please, advise
--Alex

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi Alex,

You're making it more difficult than it is.

1. Set up a dataview for one of the tables.
2. do a for each loop of the other table and search the dataview for the
value - if found, etc.
3. after you'r done, you should have found each match, and the view's find method will return the appropriate index.

HTH,

Bernie Yaeger

"Alex Ayzin" <Al********@verizon.net> wrote in message
news:eK*************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a problem that might be easy to solve(possibly, I've just

overlooked
an easy solution). Here we go:

I have a dataset with 2 datatables in it. Now, I need to do the following:
if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2")

then

txtResult.text = ds.table(1).rows(0).item("col3")

end if

The problem is, that possible match exists in the database, but not
nessasarily at Rows(0). It could be at different index. But how to

actually
get to the correct index??

I looked into the database, and in my case first possible match is at

index
Row(1) so the correct version'd be like this:

if ds.table(0).rows(1).item("col1") = ds.table(1).rows(1).item("col2")

then

txtResult.text = ds.table(1).rows(1).item("col3")

end if

But of course, there is no way to know in advance, what index to use, so

I'm
lost a bit.

Basically, I have a couple of ways of doing it. I could use Select or Find methods of datatable object to apply filtering on the datatables. But, the problem is that filtering needs to be applied on 2 different tables of the dataset, but I know how to do it for 1 datatable only. I need to merge 2
datatables into dataview and apply a filter. But how to do it? Anyway, if anyone has any ideas, so please share it with me. Thanks a lot in advance,
--Alex



Jul 21 '05 #3
Hi Alex,

Here's some code of what I have in mind; some explanatory comments within
and some explanatory notes at the end:
Dim oconn As New SqlConnection("data source=d5z0071;initial
catalog=imc;integrated security=sspi;")

oconn.Open()

Dim damaglist As New SqlDataAdapter("select * from maglist", oconn)

Dim dsmaglist As New DataSet("maglist")

damaglist.Fill(dsmaglist, "maglist")

Dim datransit As New SqlDataAdapter("select * from transit", oconn)

Dim dstransit As New DataSet("transit")

datransit.Fill(dstransit, "transit")

Dim irow As DataRow

Dim arrayseek(0) As Object

Dim ifind As Integer

Dim vue As New DataView(dstransit.Tables(0))

vue.Sort = "newbipad"

For Each irow In dsmaglist.Tables(0).Rows

arrayseek(0) = irow("bipad")

ifind = vue.Find(arrayseek)

If ifind <> -1 Then ' ie, found

MessageBox.Show(vue(ifind)("newbipad")) ' or any other col for that matter

' ifind is the index in the view - not the hard row number, but rather the
number

' in the vue, sorted by newbipad

End If

Next

oconn.Close()

Note that I simply use the two tables as separate tables within their own
dataset - I find this easier, but I could probably do this even if both were
inside the same dataset (because I would be running a for loop on one table
while searching for the match on the other table, which is what I am doing
anyway).

By way of explanation, maglist (a list of magazines) has a unique # (but a
string) called 'bipad'; transit has a list of titles with a column called
'newbipad', which is also a 6 char unique string. Maglist has about 150
rows, but transit has only about 20 - these are replaced #'s in this
industry. So I can find every maglist title that has ever undergone a bipad
change. In fact, messagebox will be called approx 15 times, once for each
time it finds a match.

Note also that I sort the dataview (vue) at the outset in newbipad order.
Finally, note that I use an object - arrayseek - to search - I use an object
like this and name it 'array' because it could have more than one element -
if, say, I was searching for a match on issue # and publisher code at once,
then arrayseek(0) and arrayseek(1) would have to be loaded and the sort
order would have to be .sort = issuecode, pubcode.

Note especially that ifind is the index inside the dataview (ie, in the
table sort if ifind is 3 then the third row sorted thus would be found by
it); if you messagebox.show ifind you will see this.

Let me know if you have any questions.

HTH,

Bernie

"Alex Ayzin" <Al********@verizon.net> wrote in message
news:e$*************@tk2msftngp13.phx.gbl...
Thank you for you reply, Bernie.

I just don't see how I'd actually get a match using this technique.
Could you elaborate a little bit?
Actually, I simply don't understand, how there is no filtering based on
multiple - datatables criterias.

Please, advise
--Alex

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
Hi Alex,

You're making it more difficult than it is.

1. Set up a dataview for one of the tables.
2. do a for each loop of the other table and search the dataview for the
value - if found, etc.
3. after you'r done, you should have found each match, and the view's

find
method will return the appropriate index.

HTH,

Bernie Yaeger

"Alex Ayzin" <Al********@verizon.net> wrote in message
news:eK*************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a problem that might be easy to solve(possibly, I've just

overlooked
an easy solution). Here we go:

I have a dataset with 2 datatables in it. Now, I need to do the following:
if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2")

then

txtResult.text = ds.table(1).rows(0).item("col3")

end if

The problem is, that possible match exists in the database, but not
nessasarily at Rows(0). It could be at different index. But how to

actually
get to the correct index??

I looked into the database, and in my case first possible match is at

index
Row(1) so the correct version'd be like this:

if ds.table(0).rows(1).item("col1") = ds.table(1).rows(1).item("col2")

then

txtResult.text = ds.table(1).rows(1).item("col3")

end if

But of course, there is no way to know in advance, what index to use, so I'm
lost a bit.

Basically, I have a couple of ways of doing it. I could use Select or Find methods of datatable object to apply filtering on the datatables. But, the problem is that filtering needs to be applied on 2 different tables of the dataset, but I know how to do it for 1 datatable only. I need to merge
2 datatables into dataview and apply a filter. But how to do it? Anyway,

if anyone has any ideas, so please share it with me. Thanks a lot in advance,
--Alex




Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tavish Muldoon | last post by:
Hello, I have a dataset with 2 tables. I want to display only selected data from one of these tables. The table names are Albums and Tracks. That Dataset is called AlbumsTracks If I only...
11
by: Nikki | last post by:
Is it possible to sort a dataset rather than a dataview? I have a web service that returns a dataset which I would like to sort before returning it (this is so the sorting is standardised and so...
0
by: Jenny C. | last post by:
Hi I am trying to do a SUM on a DataSet column with the following code // ds is the DataSet that I need to calculate data fro String filter2 = "EmpNo = " + this.EmpNo + " AND WEEK_ENDING >= '"...
2
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all....
3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
13
by: Lars Netzel | last post by:
hi! myDataSet that is fillled from an Access 2000 db and includes ONE table From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a...
2
by: Jason Huang | last post by:
Hi, I use the ReadXML method in my C# Windows Form project. Here is some of my C# code: xmlDS.ReadXml(curDir + "\\Dept.xml") ; There're 20 rows and 5 columns in the Dept.xml. But now I just...
1
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I'm working in Visual Studio 2005. I'm looking at two tables in the Data Set Designer. There's a relation between the two tables that lists 7 matching columns. Works great. One of the key...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.