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)

Recommended Answers

All 5 Replies

Not really sure what your question is here.

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...

hi can anyone help me?

HI thanks for your help guys i already solved my problem using dataset

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.