473,394 Members | 1,737 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,394 software developers and data experts.

Findrows doesnt appear to be working on multiples

RSH
I have a situation where I am filling two datasets and I need to print out
the names that appear in both datasets. I initially converted them to
dataviews, sorted on last name and performed a dataview.find on the view.
This indeed found the people that appeared in the two seperate databases
with the last name (as long as I performed a sort on the last name field
BEFORE finding). The issue immediately came up that i needed to check the
first name too. Well after searching for a bit I found the code i thought I
needed and put it in (see below) but it doesn't catch the matches, it
returns nothing everytime even though i have several matches intentionally
put in.

I have to use the datasets for comparision because the datasources with be
comparing from an Access database and a SQL Server database so a join query
will not work.

Any advice or help would be greatly appreciated.

Ron

Dim oSQLConn As SqlConnection = New SqlConnection(strConn)

Dim daCust As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
test.dbo.Customers", oSQLConn)

Dim daOldCust As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
test.dbo.OldCustomers", oSQLConn)

Dim cbCust As SqlCommandBuilder = New SqlCommandBuilder(daCust)

Dim strFN As String

Dim strLN As String

Dim dsCust As DataSet = New DataSet

Dim dsOldCust As DataSet = New DataSet

Dim intOldCustFNIndx As Integer

Dim intOldCustLNIndx As Integer

daOldCust.FillSchema(dsOldCust, SchemaType.Mapped, "OldCustomers")

daOldCust.Fill(dsOldCust, "OldCustomers")

Dim dvOldCust As New DataView

dvOldCust = dsOldCust.Tables("OldCustomers").DefaultView

oSQLConn.Open()

daCust.Fill(dsCust, "Customers")

Dim i As Integer

For i = 0 To dsCust.Tables("Customers").Rows.Count - 1

strFN = dsCust.Tables("Customers").Rows(i).Item("FN")

strLN = dsCust.Tables("Customers").Rows(i).Item("LN")

intOldCustFNIndx = 0

intOldCustLNIndx = 0

dvOldCust.Sort = "LN,FN"

Dim foundRows() As DataRowView = dvOldCust.FindRows(New Object() {strFN,
strLN})

MessageBox.Show(foundRows.Length)
Dim cnt As DataRowView

For Each cnt In foundRows

Console.WriteLine("{0}, {1}", cnt("FN").ToString(), cnt("LN").ToString())

Next

oSQLConn.Close()


Nov 21 '05 #1
2 1122
RSH,

Probably is this method simpler in this case

http://msdn.microsoft.com/library/de...sfindtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2
RSH
Good suggestion...it almost worked :-)

Here is what I ended up with:
Sub main()

Dim oSQLConn As SqlConnection = New SqlConnection(strConn)

Dim daCust As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
test.dbo.Customers", oSQLConn)

Dim daOldCust As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
test.dbo.OldCustomers", oSQLConn)

Dim cbCust As SqlCommandBuilder = New SqlCommandBuilder(daCust)

Dim strFN As String

Dim strLN As String

Dim dsCust As DataSet = New DataSet

Dim dsOldCust As DataSet = New DataSet

Dim intOldCustFNIndx As Integer

Dim intOldCustLNIndx As Integer

daOldCust.FillSchema(dsOldCust, SchemaType.Mapped, "OldCustomers")

daOldCust.Fill(dsOldCust, "OldCustomers")

oSQLConn.Open()

daCust.Fill(dsCust, "Customers")

Dim colPk(2) As DataColumn

colPk(0) = dsOldCust.Tables("OldCustomers").Columns("FN")

colPk(1) = dsOldCust.Tables("OldCustomers").Columns("LN")

dsOldCust.Tables("OldCustomers").PrimaryKey = colPk

Dim i As Integer

For i = 0 To dsCust.Tables("Customers").Rows.Count - 1

Dim foundRow As DataRow

Dim findTheseVals(1) As Object

strFN = dsCust.Tables("Customers").Rows(i).Item("FN")

strLN = dsCust.Tables("Customers").Rows(i).Item("LN")

findTheseVals(0) = dsCust.Tables("Customers").Rows(i).Item("FN")

findTheseVals(1) = dsCust.Tables("Customers").Rows(i).Item("LN")

foundRow = dsOldCust.Tables("OldCustomers").Rows.Find(findThe seVals)

If Not (foundRow Is Nothing) Then

Console.WriteLine(foundRow(2).ToString() & " " & foundRow(1).ToString())

End If

Next

End Sub

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
RSH,

Probably is this method simpler in this case

http://msdn.microsoft.com/library/de...sfindtopic.asp

I hope this helps,

Cor

Nov 21 '05 #3

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

Similar topics

7
by: JS | last post by:
Can somebody explain how to get the tablespace out of quiesce mode? I am executing on each node of my EEE Win2K system: db2 quiesece tablespace for table schema.tablename RESET I get the...
2
by: JS | last post by:
I have v8.1 fix5 using Win2k AS on 7 node logical system. I create event monitor writing to file and turn it on. Using application, I connect to db and navigate from screen to screen, generating...
5
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it...
4
by: Niki | last post by:
I'm using findrows to extract specific rows from a dataview, and then want to bind to them. I'd assumed that you bound to the array result as you would to the the dataview, but the system can't...
2
by: Showjumper | last post by:
I have a problem. Somecontrol.Attributes.Add is not working for me nor is page.registerclientscriptblock. I have created a script using the stringbuilder class. Then when i try to register it on...
2
by: =?Utf-8?B?QWxleCBGaW1pbmU=?= | last post by:
Hi all! My ASP.NET 1.1 app is working perfectly in IE7, however, when I open some page in IE6 they render as follows: 1. First dropdowns appear, then the rest of the page - looks ugly 2. When...
4
Elias Alhanatis
by: Elias Alhanatis | last post by:
Hello everybody!! I would like some help with the following problem: I have the following piece of code: from Tkinter import * root = Tk()
0
by: Rami Prilutsky | last post by:
I'm binding the dataView to a dataset (~400000 rows) and sorting it by a key (long type). I'm retrieving values from the DataView with FindRows(object key) which returns DataRowView. The...
3
by: stateemk | last post by:
Hi, I'm probably making this much harder than it needs to be, but I just can't think of how to do this. Each year, a database is created with all employees on it. I need to pull all the employees...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.