Delete rows in datatable to database

strike

New member
Joined
May 12, 2006
Messages
1
Programming Experience
Beginner
Hello,

I have troubles to delete rows in my database.

The following code will be executed when I click 'delete' button

VB.NET:
ds.Tables("dtGenres").Rows.RemoveAt(TdgGenres.CurrentCell.RowNumber)

(ds is a dataset)

So now my row is deleted in the datatable but not even in the database.

To do that, I have the following code:

VB.NET:
Dim sqlDeleteGenre As String
sqlDeleteGenre = _
    "delete from tblGenre where id=?"

With daGenre
   .DeleteCommand = New OleDbCommand(sqlDeleteGenre, cnn)
   .DeleteCommand.Parameters.Add("genid", OleDbType.BSTR, 2, "GenId")
End With

daGenre.Update(ds, "dtGenres")
ds.Tables("dtGenres").AcceptChanges()

daGenre is my oleDbDataAdapter.

When I execute this code, there is no Exception but my rows are still in my database

Anyone how knows what the problem is?

Thx 4 reply!
 
the following maybe helpful, pls try:

ds.Tables("dtGenres").Rows(rownumber).delete
daGenre.update(ds.Tables("dtGenres").getchanges(datarow.deleted))
ds.Tables("dtGenres").acceptchanges

where rowumber is the number of the row in your table, which start with 0 to the number of tableRows - 1

I hope this would be helpful
 
Back
Top