|This tip was submitted by Charles
Here is a clever datawindow trick which determines if there are duplicate rows in the datawindow
before saving to the database. In the example below, the unique key in the database is "user_id",
so what we are doing here is sorting them and then filtering in a way which leaves only the duplicate rows.
If the row count is greater than zero after the sort, there is a problem... no looping necessary!
//now use this sort and filter to leave only duplicate rows
lds_buffer.SetSort ("user_id A")
lds_buffer.SetFilter ("user_id = user_id[-1]")
if lds_buffer.RowCount() > 0 then
//got a dup, tell the user which one!
al_row = lds_buffer.GetItemNumber (1, "row_num")
as_colname = "user_id"
as_error = "Duplicate User ID."
//no dups, so clear the filter and do the update...