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

Comparing DataTables and Removing Rows VB.NET

Hey Everyone,

I'm having an issue that I hope someone can help me out with. If I have 2 DataTables (one that reads data from a DB and one that reads from a XML file), is there a way to combine them and eliminate any records that are duplicated. What I'm trying to do is build an app for a realtor that uses a RETS Connector, and I'm required to write the data to a XML file rather than another database for reasons that really aren't worth going into. But if you aren't familiar with a RETS Connection, you have to pull the data, write it how you want, and then you can use it on your site to your liking. They limit the connections so I can't just feed off of their database.

The client wants to be able to update the properties on a daily basis, so in order to eliminate a 12-hour wait time to download the property data by starting over, I'm trying to use the current xml file to fill a data table and compare it to another data table that is created when I search the RETS feed. If I can combine the data tables after they are filled and possibly combine/sort them, then eliminate any records that are duplicated (remove the original and duplicate), that will leave me with only the new properties. Then I can take that data to do the actual request for images, etc. Did I lose you?

If anyone has any ideas or links, please send them my way. Many thanks for any help.

This is a VB.NET web application.
Sep 19 '08 #1
3 4765
balabaster
797 Expert 512MB
Hmm, quick hack perhaps, create a third datatable that is a copy of your first, and then iterate through the second table and where each row doesn't exist, add it to the table. Now table 3 holds all the unique records...

LINQ would be a great tool for this.
Sep 19 '08 #2
Hmm, quick hack perhaps, create a third datatable that is a copy of your first, and then iterate through the second table and where each row doesn't exist, add it to the table. Now table 3 holds all the unique records...

LINQ would be a great tool for this.

Thanks for the quick reply! Do you know what the syntax is for determining if a row exists. Sorry I'm still kind of new at this stuff. I had a table.select(filterexpression) set up before and used a loop to go through and try to find records but it took forever. I'll look into LINQ, but I'm on a time limit for this, so if it's something that's going to require me to do a lot of research and code changes to implement, I think it's off the table...no pun intended :).
Sep 19 '08 #3
balabaster
797 Expert 512MB
Thanks for the quick reply! Do you know what the syntax is for determining if a row exists. Sorry I'm still kind of new at this stuff. I had a table.select(filterexpression) set up before and used a loop to go through and try to find records but it took forever. I'll look into LINQ, but I'm on a time limit for this, so if it's something that's going to require me to do a lot of research and code changes to implement, I think it's off the table...no pun intended :).
um...not exactly sure as I've not yet had to use LINQ for an "Exists" clause...I just hacked this together, so it'll need some tweaking, but it should give you an idea:
Expand|Select|Wrap|Line Numbers
  1.         Dim tbl1 As New DataTable 'The table from the database
  2.         Dim tbl2 As New DataTable 'The table from the XML (the ones we previously downloaded I'm assuming)
  3.         Dim qry = From x In tbl1 _
  4.                   Where Not (From y In tbl2 _
  5.                              Select y.Field("KeyColumn")).Contains(x.Field("KeyColumn")) _
  6.                   Select x
  7.  
  8.         For Each TableRow In qry
  9.             'Add the content of the row to the XML
  10.         Next
Sep 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Job Lot | last post by:
Is there anyway of Joining two or more DataTable with similar structure? I have three DataTables with following structures Data, AmountB/F, Repayments, InterestCharged and AmountC/F i want...
1
by: Gene Ariani | last post by:
I have one dataset that contains two DataTables: DataTable1: Customer_ID 1
9
by: DraguVaso | last post by:
Hi, I have two DataTables (our DataViews or whatever that will suit the best for the solution). I want to merge these two DataTables the fastest as possible, but they have to be merged one table...
4
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...
5
by: Frank | last post by:
Hello All, I am working on a vb.net app where I need to compare to 2 datatables and determine if a string exists in one or both. The first dt is filled from the db. A form is loaded and the...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
2
by: c_shah | last post by:
Scenario: I have to update my SQL server table from an ORACLE database to keep my SQL table in sync with ORACLE. I have one data table that is populated form ORACLE and other one is populating...
3
by: bbdobuddy | last post by:
Hi, I have two datatables that I want to left outer join and then do some queries on but I having a hard time figuring out how to join the datatables together. One of the datatables comes from...
3
by: laurasaur | last post by:
Hi everyone, I have 2 listboxes that I need to move items between, they are both bound to DataTables which get populated from the database with a list of clients. Im getting a few problems,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.