my deletecommand delete all my rows whenever i delete a row..but when i view it again the other rows still there and the i deleted is actually deleted..

here's my code
for da.deletecommand

da.DeleteCommand = New SqlCommand("Delete from Admission_Record WHERE Patient_ID = @Patient_ID", cs)
        da.DeleteCommand.Parameters.Add("@Patient_ID", SqlDbType.VarChar).Value = ds.Tables(0).Rows(bs.Position)(0)

        cs.Open()
        da.DeleteCommand.ExecuteNonQuery()
        cs.Close()
        ds.Clear()
        da.Fill(ds)

my deletecommand would delete all those rows on my datagrid but i just selected one row and delete it..my problem is it delete all rows, then i close the application.. and when i open it again the deleted row is gone and the other rows are there..

add a field(Deleted as Boolean) in your table.... Then used update statement instead of delete...

query= "UPDATE YourTableName SET Deleted = 1 WHERE YourCondition"

when your viewing records

query= "Select Yourfield frm YourTableName where Deleted = 'false'"

Deleted = 'false'(view Records)
Deleted = 'true'( no records)... that's what am i doing...

This question has already been answered. Start a new discussion instead.