Dim dt2 As DataTable=DataTables("nvccsvalue")
For Each dr As DataRow In dt.DataRows
If dt2.Compute("count(Valueid)","Valueid='"& dr("Valueid") &"'")>0 Then
Dim dr1 As DataRow=dt2.find("Valueid='"& dr("Valueid") &"'","timebegin desc")
If dr1 IsNot Nothing Then
If Format(dr1("timebegin"),"yyyy-MM-dd")=Format(Date.Now(),"yyyy-MM-dd") Then
dr1("idvalue")=val(Rand.Next(100))
Else
Dim dr3 As DataRow=dt2.AddNew()
dr3("Valueid")=dr1("Valueid")
dr3("timebegin")=Date.Now()
dr3("idvalue")=val(Rand.Next(100))
dr3.Save()
End If
End If
Else
Dim dr2 As DataRow=dt2.AddNew()
dr2("Valueid")=dr("Valueid")
dr2("timebegin")=Date.Now()
dr2("idvalue")=val(Rand.Next(100))
dr2.Save()
Continue For
End If
Next