472,126 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

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{tempdeleteditemstable})"

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
Mar 11 '08 #1
2 1539
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

Mar 12 '08 #2
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]" <no************@planet.nlwrote in message
news:E8**********************************@microsof t.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

Mar 12 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jim Michaels | last post: by
9 posts views Thread by Hamed | last post: by
24 posts views Thread by Frank Swarbrick | last post: by
flexsingh
5 posts views Thread by flexsingh | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.