D
darrel
When I write scripts for deleting records in databases, I tend to do it in
this fashion:
- delete link passes ID to a delete.aspx page
- delete.aspx page queries db using that ID to retrieve the file
information
- page displays file information with a 'are you sure you want to delete'
confirmation button.
- upon clicking said button, I delete the record.
Simple enough.
At times, though, I need to delete multiple records related to one record as
well as actual files in the filesystem related to the record.
In that case, I tend to use this method:
- delete link passes ID to a delete.aspx page
- delete.aspx page queries db using that ID to retrieve the file
information
- page displays file information with a 'are you sure you want to delete'
confirmation button.
- upon clicking said button, I requery the db to get the data again
- I loop through the dataset returned to delete the related content first,
then delete the parent record
In that method, I query the DB twice for essentially the same data.
Would it make more sense to query once, then store the data in the viewstate
(if I can). Or is it not a big deal to just do a double query.
As these are small datasets, it's probably a moot issue at this point, but
for future reference, I'd like to understand the best practices for this
type of situation.
-Darrel
this fashion:
- delete link passes ID to a delete.aspx page
- delete.aspx page queries db using that ID to retrieve the file
information
- page displays file information with a 'are you sure you want to delete'
confirmation button.
- upon clicking said button, I delete the record.
Simple enough.
At times, though, I need to delete multiple records related to one record as
well as actual files in the filesystem related to the record.
In that case, I tend to use this method:
- delete link passes ID to a delete.aspx page
- delete.aspx page queries db using that ID to retrieve the file
information
- page displays file information with a 'are you sure you want to delete'
confirmation button.
- upon clicking said button, I requery the db to get the data again
- I loop through the dataset returned to delete the related content first,
then delete the parent record
In that method, I query the DB twice for essentially the same data.
Would it make more sense to query once, then store the data in the viewstate
(if I can). Or is it not a big deal to just do a double query.
As these are small datasets, it's probably a moot issue at this point, but
for future reference, I'd like to understand the best practices for this
type of situation.
-Darrel