You should create a unique index in the table to disallow the duplication:
create unique index on myTable (number, naam);
This way you cannot enter duplicates. Reference: CREATE INDEX
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a database on the net and consist of 2 tabels i.e. Naam of the employee and his number.
number naam
1000 Rinaldo
1001 Other
how can i add a name and number without getting uplicates. I've found som on the net with google and is Linq what i do not get. Example in LINQ c# Please guide me to the process.
var group = dt.AsEnumerable().GroupBy(row => row.Field<string>("Personeel")).Select(g => new
{
group = g.Key,
first = g.Max(row => int.Parse(row.Field<string>("Naam"))).ToString(),
second = g.Max(row => row.Field<int?>("PersoneelsNummer") ?? 0)
}).ToList();
other I have tryed:
var group = dt.AsEnumerable().GroupBy(row => row.Field<string>("Personeel")).Select(g => new
{
group = g.Key,
first = g.Max(row => int.Parse(row.Field<string>("Naam"))).ToString(),
second = g.Max(row => row.Field<int?>("PersoneelsNummer") ?? 0)
}).ToList();
Al coming from StackOverflow
https://stackoverflow.com/questions/58835299/find-duplicates-in-a-datatable-then-compare-duplicates
You should create a unique index in the table to disallow the duplication:
create unique index on myTable (number, naam);
This way you cannot enter duplicates. Reference: CREATE INDEX