将新输入数据与ASP.Net中的表记录进行比较 [英] Compare new input data with record on table in ASP.Net
问题描述
嗨!,
我需要一种方法来做到以下几点:
我要拿.csv数据并将其保存到表中。然后,我必须测试刚刚获取并保存到表中的新数据,并将其与具有我正在查找的记录的表匹配。
我有两个表,Table1用于保存所有数据,Table2有一个记录列表(这是我需要匹配的记录)。所以我必须检查传入的记录是否与我感兴趣的记录匹配在表2中。
如果记录存在,那么电子邮件/短信应该是发送通知我记录已经匹配,然后该记录应该被标记为已经过测试,以便我不再测试它,因为传入的数据被保存。
请协助。
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.
推荐答案
尝试这个
TRY THIS
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
}
只需使用以下方法
使用数据表Comper选项
DataTable.Compaer(datable2)它是带有Un Matach Row的返回数据表
Just Use the Following method
use Data Table Comper Option
DataTable.Compaer(datable2) It's Return Data table With Un Matach Row
这篇关于将新输入数据与ASP.Net中的表记录进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!