i've a problem with deleting record from datagrid. i have few columns in my datatable and all publish on to a grid and under "ID" column there are id nos and they are "NOT" unique. user able to search using this "ID" no. problem comes in deleting records since the "ID" is not unique. if i use following command to delete; it deletes all the records which are having same "ID". but i want to delete only the current row records,

sqlDelete = "DELETE * FROM table1 WHERE ID ='" & form1.dgv1.CurrentRow.Cells(0).Value.ToString & "'"

any help. thanks in advance.

hello !
when ever there is a situation like this then always use two or more then two condition for updating and deleting records. for example . you have many fields in grid , one of them is ID and 2nd one is Name , just do like this

sqlDelete = "DELETE * FROM table1 WHERE ID ='" & form1.dgv1.CurrentRow.Cells(0).Value.ToString & "' and name='"& form1.dgv1.CurrentRow.Cells(0).Value.ToString & "'"

If please provide all columns name then i can able to provide you a good solution. if i helped you please mark this thread solved and vote me up .

Regards

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.