Hi to all,
I have always had this problem where: if I have a datagrid with records like

RecID Name
2 Tom
5 Rich
6 Harry

To Save I will loop through the rows using the sql
IF NOT EXISTS(SELECT * FROM myTable WHERE RecID= dgv.rows(i).cells(0).value say)
BEGIN INSERT the row.(the use INSERT COMMAND)

At the end of the loop I have to delete all records whose RecID are not in the Datagrid.
My Problem is:
How do I create a kind of list of datagrid RecIDs and do something like
DELETE FROM myTable WHERE RecID NOT IN (2,5,6)

Thanks in advance

I miss any VB.NEt code?
What you want to do, there is no way to do it with just SQL

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.