Is it possible to check for existence of a particular row in a datatable?
suppose if there are two rows in datatable, is it possible to check whether the third row exists or not?
For j As Integer = 0 To dtemp.Rows.Count - 1
If dtemp.Rows(j)("empcode").ToString.Trim <> dt.Rows(j)("empcode").ToString.Trim Then
'Insert code
End If
Next
Are you trying to see if your data is existing or not?
Let's say: If you are inserting data in your database, then you can use the textbox property tag to see whether the data is existing or not.
If Me.txtFirstName.Tag = 0 Then
sSQL = "INSERT INTO tblAddressBook ( last_name, first_name, mid_name, birth_date, gender, home_adr, bus_adr, tel_no, mobile_no, email)"
sSQL = sSQL & " VALUES(@last_name, @first_name, @mid_name, @birth_date, @gender, @home_adr, @bus_adr, @tel_no, @mobile_no, @email)"
cmd.CommandText = sSQL
Else
sSQL = "UPDATE tblAddressBook set last_name = @last_name, first_name = @first_name, mid_name = @mid_name, birth_date = @birth_date, gender = @gender"
sSQL = sSQL & " ,home_adr = @home_adr, bus_adr = @bus_adr, tel_no = @tel_no, mobile_no = @mobile_no, email = @email where contact_id = @id"
cmd.CommandText = sSQL
End If
...or else it will update that data in your database. The code above should give you an idea. SINCE you didn't show your code let's talk on this one.
如果DataRow.Table.Columns.Contains(“ column”)然后MsgBox(“ YAY”)结束
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.