Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!,

I need a way of doing the following:

I am fetching .csv data and saving it to a table. I have to then test the new data that I just fetched and saved to a Table and match it to the table that has records that I am looking for.

I have two table, Table1 for saving all data and Table2 which has a list of records(this are the records I need to match against). So I have to check if the incoming record matches the one that I am interested in which are in Table2.

If the record exist, then an email/sms should be sent to notify me that the records has been matched and then that record should be flaged that it has been tested so that I don't test it again as the incoming data are saved.

Please assist.
Posted
Comments
FinickyCoder 27-Feb-15 3:10am    
not getting what u r trying to say...
justicet 3-Mar-15 2:15am    
Hi!,

Ok, I have two table. Table1 and Table2, Table1 saves all incoming data and Table2 has data that I need to match with.

If data that is being saved to Table1 matches data in Table2 then an email/sms has to be sent.

Hope I have made it simple.
FinickyCoder 3-Mar-15 2:46am    
wait i will be back with the code... :) ;)

TRY THIS


C#
dt3 = getatable1();// table with 2 columns name,address
       dt4 = getatable2();// table with 2 columns name,address


       for (int i = 0; i < dt3.Rows.Count; i++)
       {
           for (int j = 0; j < dt3.Columns.Count-1; j++)
           {

               int k = 0;


               while (dt3.Rows[i][0].ToString()!= dt4.Rows[k][0].ToString() )
               {
                   k = k + 1;
               }

if (dt3.Rows[i][0].ToString()==dt4.Rows[k][0].ToString())//go on comparing like this
 //no need to go for this 2nd if and while loop, if ur 0th column of both tables is primary key or unique key

              
{
                   while (dt3.Rows[i][1].ToString() != dt4.Rows[k][1].ToString())
                    {

                        k++;

                    }
    Response.Write(dt3.Rows[i][0].ToString() + " =  " + dt4.Rows[k][1].ToString() + "<br>"); //use ur code for email/sms


                }
 
Share this answer
 
v3
Just Use the Following method

use Data Table Comper Option

DataTable.Compaer(datable2) It's Return Data table With Un Matach Row
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900