473,503 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing Two DataSets

In one of the applications that I'm working on I have 2 sets of
functions that build different datasets.

Imagine 4 columns in a datagrid. Inside those 4 columns I have nested
datalists. Two of the datalists' datasources point to database A and
the other two point to database B. This effect allows the client to
perform a side-by-side comparison of the same product so that records
can be updated accordingly. It's easy enough to scroll down and look
for differences but I was asked to make it even easier for the client.
The ultimate goal is to have any changes displayed in red or bold type
so that differences can be spotted at first glance. An example would be
that if Database A has product XYZ's latest version at 3 and Database B
has product XYZ's latest version at 4, then the 4 would be displayed in
red or bold type.

I'm thinking that a cookie might be the way to go but I could be wrong.
Does anyone have any suggestions or references that I can check out to
compare datasets row-by-row? Is there an easier way to go about doing
this?

Nov 19 '05 #1
19 2955
Can you join the relevant tables in SQL? Cross database joins are quite
straight forward if you have the necessary permissions. That way you could
flag your interest using computed columns. Probably more efficient than
regular coding.

"Will Lastname" wrote:
In one of the applications that I'm working on I have 2 sets of
functions that build different datasets.

Imagine 4 columns in a datagrid. Inside those 4 columns I have nested
datalists. Two of the datalists' datasources point to database A and
the other two point to database B. This effect allows the client to
perform a side-by-side comparison of the same product so that records
can be updated accordingly. It's easy enough to scroll down and look
for differences but I was asked to make it even easier for the client.
The ultimate goal is to have any changes displayed in red or bold type
so that differences can be spotted at first glance. An example would be
that if Database A has product XYZ's latest version at 3 and Database B
has product XYZ's latest version at 4, then the 4 would be displayed in
red or bold type.

I'm thinking that a cookie might be the way to go but I could be wrong.
Does anyone have any suggestions or references that I can check out to
compare datasets row-by-row? Is there an easier way to go about doing
this?

Nov 19 '05 #2
Jeb: I wish I could as this would make the most sense. The only problem
is that one database is MS Access and one is SQL.

Nov 19 '05 #3
Will,

What about putting both tables into the same dataset and creating a
relationship?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
In one of the applications that I'm working on I have 2 sets of
functions that build different datasets.

Imagine 4 columns in a datagrid. Inside those 4 columns I have nested
datalists. Two of the datalists' datasources point to database A and
the other two point to database B. This effect allows the client to
perform a side-by-side comparison of the same product so that records
can be updated accordingly. It's easy enough to scroll down and look
for differences but I was asked to make it even easier for the client.
The ultimate goal is to have any changes displayed in red or bold type
so that differences can be spotted at first glance. An example would be
that if Database A has product XYZ's latest version at 3 and Database B
has product XYZ's latest version at 4, then the 4 would be displayed in
red or bold type.

I'm thinking that a cookie might be the way to go but I could be wrong.
Does anyone have any suggestions or references that I can check out to
compare datasets row-by-row? Is there an easier way to go about doing
this?

Nov 19 '05 #4
That sounds like it would be the best bet but I'm wondering how much
work would go into implementing it.

I have 4 functions that I call for the Access database and the same 4
functions for the SQL database. The only difference being minor SQL
syntax differences.

Are there any sites or references that you could suggest?

Nov 19 '05 #5
Will,

You'll have to run all your SQL statements either way, but then once you
have all the tables in a dataset you can create the relationship(s). Here's
a snippet of code that shows how to create a relationship.

' Create and fill the DataSet.
m_DataSet = New DataSet
m_da_Addresses.Fill(m_DataSet, "Addresses")
m_da_TestScores.Fill(m_DataSet, "TestScores")

' Define the relationship between the tables.
Dim data_relation As New _
DataRelation("Addresses_TestScores", _
m_DataSet.Tables("Addresses").Columns("ContactID") , _
_
m_DataSet.Tables("TestScores").Columns("ContactID" ))
m_DataSet.Relations.Add(data_relation)

Once your relationships are created you can do some pretty neat things with
DataViews I think you should be able to query your tables and look for like
names but with different numbers. It will take some experimentation. I would
google for info on creating relationship

Take a look at the code at the bottom of this page:

http://www32.brinkster.com/srisamp/n...article_15.htm

It's very similar to what you might do.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
That sounds like it would be the best bet but I'm wondering how much
work would go into implementing it.

I have 4 functions that I call for the Access database and the same 4
functions for the SQL database. The only difference being minor SQL
syntax differences.

Are there any sites or references that you could suggest?

Nov 19 '05 #6
Again Justin, always coming through in the clutch!

Thanks a million!

Nov 19 '05 #7
I also read another article about storing multiple database tables in
the dataset. Will I run into problems with the fact that both databases
have the exact same field names?

Nov 19 '05 #8
For instance, if I have the datalist's datasource set to
'FunctionGetItemVersionByProductID(ProductID) and I have in my
itemtemplate: <%# DataBinder.Eval(Container.DataItem, "ProductName")
%>, won't there by 2 instances of Product name and in turn throw an
error?

Nov 19 '05 #9
Will,

Bind the datatable and not the entire dataset. Then it won't matter.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
For instance, if I have the datalist's datasource set to
'FunctionGetItemVersionByProductID(ProductID) and I have in my
itemtemplate: <%# DataBinder.Eval(Container.DataItem, "ProductName")
%>, won't there by 2 instances of Product name and in turn throw an
error?

Nov 19 '05 #10
I read some related articles very thoroughly and have at least a
general understanding of how to create the datatable. I have about 8
functions that are tied to my datalists that retrieve data. Each
function has different SQL statements that retrieve specific pieces of
data. What would be the best way of "concatenating" onto my current
datatable? If I dim a new datatable in each function won't the
information keep getting rewritten? I haven't found any literature
online in regards to this matter. Everything I've come across
presupposes that there is one subroutine with 2 or more datasets.

Nov 19 '05 #11
You can add as many datatables to a dataset as you'd like to. You just have
to make certain that each datatable has a different name.

For example (Assuming you already have a dataset that contains one or more
datatables) you may add another like so:

Public Function AddTableToDataSet(ByVal dataSetToAddTo As DataSet, ByVal
sqlCommand As SqlCommand, ByVal dataSetTableName As String) As DataSet

Try

Dim FortunateDataAdapter As SqlDataAdapter =
GetDataAdapter(sqlCommand)

FortunateDataAdapter.Fill(dataSetToAddTo, dataSetTableName)

Return dataSetToAddTo

Catch e As Exception

Throw e

End Try

End Function

Sincerely,

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I read some related articles very thoroughly and have at least a
general understanding of how to create the datatable. I have about 8
functions that are tied to my datalists that retrieve data. Each
function has different SQL statements that retrieve specific pieces of
data. What would be the best way of "concatenating" onto my current
datatable? If I dim a new datatable in each function won't the
information keep getting rewritten? I haven't found any literature
online in regards to this matter. Everything I've come across
presupposes that there is one subroutine with 2 or more datasets.

Nov 19 '05 #12
So to test this I created a dataset with 2 tables. Let's just say
Table1 and Table2. In going through my FOR Next Loop I tried the
following:

For i = 0 To dsRowCount - 1
If ds.Tables("Table1").Rows(i)("ColumnName") <>
ds.Tables("Table2").Rows(i)("ColumnName") Then
response.write("not the same")
Else
resposne.write("ok")
End If
Next i

I am getting an "Object reference not set to an instance of an object."
error when I attempt this. Any suggestions or pointers?

Nov 19 '05 #13
I filled one of the datasets in Function A and the other in Function B
and returned them. Am I not able to access them this way?

Nov 19 '05 #14
Will,

Running in debug mode, does your for next loop error out right away, or make
it through at least one iteration first?

I'm wondering if your tables have the same number of columns in them. If
they don't...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
So to test this I created a dataset with 2 tables. Let's just say
Table1 and Table2. In going through my FOR Next Loop I tried the
following:

For i = 0 To dsRowCount - 1
If ds.Tables("Table1").Rows(i)("ColumnName") <>
ds.Tables("Table2").Rows(i)("ColumnName") Then
response.write("not the same")
Else
resposne.write("ok")
End If
Next i

I am getting an "Object reference not set to an instance of an object."
error when I attempt this. Any suggestions or pointers?

Nov 19 '05 #15
It errors even if I try:

response.write(ds.Tables("Table").Rows(0)("ColumnN ame"))

I'm getting so frustrated with this.

Thanks for helping out!

Nov 19 '05 #16
Well, then it's not finding any columns at all for that table.

Try this code (it uses index numbers for the table, rows, columns so that if
the problem is the wrong table name you'll know):

'---Start by making certain that the dataset actually contains at least the
one table.
If ds.Tables(0) Is Nothing Then
Response.Write("Table Not Found!" & "<br>")
Else
'---Check if any rows exist
If ds.Tables(0).Rows.Count > 0 Then
Response.Write(ds.Tables(0).Rows.Count.ToString & "<br>")
Response.Write(ds.Tables(0).Rows(0).Columns(0).Col umnName)
Else
Response.Write("No Rows Found!")
End If
End If

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
It errors even if I try:

response.write(ds.Tables("Table").Rows(0)("ColumnN ame"))

I'm getting so frustrated with this.

Thanks for helping out!

Nov 19 '05 #17
This writes the name of the column name in the function where I fill
the dataset. If I try to compare a dataset in another function to this
dataset then I get an error.

Nov 19 '05 #18
Will,

I didn't realize you were declaring the dataset object inside of one
function and then using it again in another...

Objects declared within a function are only available within that function.

Instead declare your dataset object as a dataset outside of the first
function near the top of the page but inside of the class.

Private ds As DataSet

Then fill the dataset inside of your first function.

Private Function Number1()
'---Fill ds here
End Function

You won't have to declare ds inside of the function it's available
throughout the whole class.

Now it won't be nothing in the second function.
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Will Lastname" <wh****@brinkster.net> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
This writes the name of the column name in the function where I fill
the dataset. If I try to compare a dataset in another function to this
dataset then I get an error.

Nov 19 '05 #19
Object reference not set to an instance of an object

Still getting this. I'm going to have to bag this idea for now.

Nov 19 '05 #20

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

Similar topics

1
10396
by: Eric | last post by:
Hello, I am trying to write a webservice to compare 2 datasets, one recieved from a client, and the other taken from a database on the webserver. Sofar, I have had little success in...
4
1725
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset...
0
1270
by: Elliot M. Rodriguez | last post by:
I can accomplish this relatively easily but inefficiently, and it seems like a hack, but I cant think of a better workaround. Hopefully someone else here can. My task is to perform an update on...
9
2878
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
4
3704
by: Frank | last post by:
Hello, Developing an app where the user fills out a sometimes quite lengthy form of chkboxes, txtboxes, radbtns, etc. User responses are saved to a mySql db, which the user can later edit. When...
0
1203
by: S.Tedeschi | last post by:
Hi all; as posted some days ago, I'm converting an on-line app; I used to heavily rely on strongly-typed DataSets directly dropped onto pages, and so viewed by code(-behind) as well. In the next...
5
1839
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new...
12
3550
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
9
1930
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
0
7202
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
7332
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...
1
6991
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...
0
7462
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...
0
5578
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
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...
0
1512
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 ...
1
736
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.