我尝试在表格中发送数据,当时间超过5个薄荷数据成功插入但数据插入多次我想只提交一次数据 即只有一行只插入一次
这是我尝试的
if (timediff.TotalMinutes > 5)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var u = db.tbl_urgent_contacts;
foreach (var a in u)
{
tbl_OutBox tb = new tbl_OutBox();
tb.FromSIM_No = a.SimNo;
tb.ToSIM_No = a.SimNo;
tb.ToText = "Check abc";
tb.Reply = "NA";
tb.Response = "NA";
tb.RegNo = "NA";
tb.Datetd = DateTime.Now;
tb.FFID = "NA";
tb.UserId = "You";
tb.FromText = "Check abc";
db.tbl_OutBoxes.InsertOnSubmit(tb);
db.SubmitChanges();
}
}
答案 0 :(得分:1)
修改此声明: if(timediff.TotalMinutes> 5) 至: if(timediff.TotalMinutes == 5)
我希望它对你有用