473,598 Members | 3,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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).row s(0).item("col1 ") = ds.table(1).row s(0).item("col2 ") then

txtResult.text = ds.table(1).row s(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).row s(1).item("col1 ") = ds.table(1).row s(1).item("col2 ") then

txtResult.text = ds.table(1).row s(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 3146
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********@ver izon.net> wrote in message
news:eK******** *****@TK2MSFTNG P12.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).row s(0).item("col1 ") = ds.table(1).row s(0).item("col2 ") then
txtResult.text = ds.table(1).row s(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).row s(1).item("col1 ") = ds.table(1).row s(1).item("col2 ") then
txtResult.text = ds.table(1).row s(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*****@cherwe llinc.com> wrote in message
news:OO******** ******@TK2MSFTN GP11.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********@ver izon.net> wrote in message
news:eK******** *****@TK2MSFTNG P12.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).row s(0).item("col1 ") = ds.table(1).row s(0).item("col2 ")

then

txtResult.text = ds.table(1).row s(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).row s(1).item("col1 ") = ds.table(1).row s(1).item("col2 ")

then

txtResult.text = ds.table(1).row s(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;int egrated security=sspi;" )

oconn.Open()

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

Dim dsmaglist As New DataSet("maglis t")

damaglist.Fill( dsmaglist, "maglist")

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

Dim dstransit As New DataSet("transi t")

datransit.Fill( dstransit, "transit")

Dim irow As DataRow

Dim arrayseek(0) As Object

Dim ifind As Integer

Dim vue As New DataView(dstran sit.Tables(0))

vue.Sort = "newbipad"

For Each irow In dsmaglist.Table s(0).Rows

arrayseek(0) = irow("bipad")

ifind = vue.Find(arrays eek)

If ifind <> -1 Then ' ie, found

MessageBox.Show (vue(ifind)("ne wbipad")) ' 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********@ver izon.net> wrote in message
news:e$******** *****@tk2msftng p13.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*****@cherwe llinc.com> wrote in message
news:OO******** ******@TK2MSFTN GP11.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********@ver izon.net> wrote in message
news:eK******** *****@TK2MSFTNG P12.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).row s(0).item("col1 ") = ds.table(1).row s(0).item("col2 ")

then

txtResult.text = ds.table(1).row s(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).row s(1).item("col1 ") = ds.table(1).row s(1).item("col2 ")

then

txtResult.text = ds.table(1).row s(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
10520
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 wanted to select those tracks that had a common AlbumID as those in Albums - how would I get this out of a dataset?
11
16367
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 applications that see the results as xml don't have to fiddle around and sort it themselves later). I have tried sorting a dataview and adding that dataview's table to the dataset but the results don't remain sorted. The only way I can see to do...
0
1178
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 >= '" + MyDateTime.Date.ToShortDateString() + "'" float totalGross = Convert.ToSingle(this.ds.Tables.Compute("SUM(GROSS)", filter2)) float totalEarn = Convert.ToSingle(this.ds.Tables.Compute("SUM(Earns)", filter2)) Here the problem: it doesn't...
2
5335
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. I then use a Dataview to filter this view using a keyword and I have no problems with this either. What I would like to do is to save this Dataview to a new Dataset so I can save the reslts to a new file but here is where I am having the...
3
1244
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 ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2") then txtResult.text = ds.table(1).rows(0).item("col3")
13
1820
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 DataView cause I do a lot of filtering) The problem is the primary key field (a unique counter), let's call it "TBL_ID".
2
3698
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 want some of the data in the Dept.xml, e.g., DeptLevel >1 AND Status=0. How do I filter the XML or xmlDS so that the output is what I need?
1
1464
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 columns from each table is called "Team". Valid values are F1 through F7, and when they match, the result set works exactly like you'd think it would. The problem is that somebody decided to put in a "Team" value of ALL, which
3
2830
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 dataset to data in a second dataset, using a common key. I will first describe the problem in words and then I will show my code, which has most of the solution done already. I have built an ASP.NET that queries an Index Server and returns a...
0
7902
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8265
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6719
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.