Deleting multiuple rows from a database...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brad Pears

    Deleting multiuple rows from a database...

    I am working on a new vb.net 2005 project using SQL server 2000 as the
    backend db.

    I have a listview where control I want a user to be able to select either
    just one or multiple rows in the listview and perform an action on them. If
    the user chooses to delete these rows I wonder what the best way to handle
    the deletion of multiple rows is...

    Right now I have a stored procedure for deleteing jsut opne row. i.e delete
    from {tablename} where field1 = Parm1". However, if the user selects say 10
    rows, should I loop through the lsitview items and call this SP each time,
    OR can I somehow batch them so that I can run the stored procedure just
    once - which would then delete all selected rows using a clause similiar to
    the following.... "delete from {tablename} where field1 in (select field1
    from{tempdelete ditemstable})"

    Any ideas if this is the best way to do it - or is simply looping through
    the listview and calling the stored proc to do a single row delete each time
    ok? They would never be deleting that many items at once - but definately
    there may be times when multiple deletes will be required...

    Thanks, Brad


  • Cor Ligthert[MVP]

    #2
    Re: Deleting multiuple rows from a database...

    Brad,

    The best way is to use a Data related control like the DataGridView or the
    DataGrid (eventualy with no row and column headers) and for sure not the
    listview which is more intended for things as showing things like files.

    Cor

    Comment

    • Brad Pears

      #3
      Re: Deleting multiuple rows from a database...

      Never been a fan of the datagrid at all- just doesn't give you the proper
      control I have found. It's always seemed clumsy to me and hard to really do
      what you want with it...

      I have not tried the datagridview. Maybe I should take a look at it...

      Thanks, Brad

      "Cor Ligthert[MVP]" <notmyfirstname @planet.nlwrote in message
      news:E8696DBF-DEB3-4347-9CC9-9F67512EB5C2@mi crosoft.com...
      Brad,
      >
      The best way is to use a Data related control like the DataGridView or the
      DataGrid (eventualy with no row and column headers) and for sure not the
      listview which is more intended for things as showing things like files.
      >
      Cor

      Comment

      Working...