 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 8th, 2004, 05:57 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Add,update,del data- Best practice?
I want to maintain a database. Wanted to know the best way to do it. Do people usually have one form with Add, UPDATE and DELETE buttons and hide the unwanted button..like hide update and delete during Add; hide ADD during update/delete. If yes, then where do we pass the parameters.Right now I am passing "ADD" as an ID in the response.redirect if it is an ADD and passing the primary key if it is update. Then on the resulting page, checking the request querystring if it is "ADD" or not. I am sure there is a better way to do this.Also, how do we best use the connection. Do we open it each time we add/update. I earlier used wizard to generate the code for showing the data in the datagrid.All the connections and commands were generated automatically. So, really not sure if I should code them manually or open a new connection to add/update the record.I am using vS.NET 2003.
Thanks
Renu
|
|

August 8th, 2004, 08:42 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi there,
You can show/hide those buttons by requesting for the BUTTON_NAME/ID and checking for its value property. If ADD, hide the others, likewise if Update/Delete, hide the add. Or go for a hidden field, whichever you are comfortable with. I wouldn't say you use Querystring for that, as it is visible to the user and the user can play around with it.
You can also check the code of the Wizard built project, to find on the connection front, and see how that was used. IMO, I would say, use connection when needed(each time you add/edit/delete) and close once done.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

August 9th, 2004, 01:17 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Vijay.
1) But how do I pass parameters for "ADD" or "UPDATE/DELETE". How does the detail page know what buttons to show, since querystring is not a good idea.
2) I am using a datagrid to show the results and have the option to sort by column. I believe, by sorting the column, the data is rearranged but the rows still have the same index, the indexes are not rearranged. This causes a problem of not loading the correct page based on the row index.
|
|

August 9th, 2004, 09:58 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Renu,
1) When you do a form submit, the page to which it got submitted(I believe it is the same page in your case)
strAction = Request("BUTTON_ID")
Or
strAction = Request("BUTTON_NAME")
strAction will hold the Value of the BUTTON. That way you can know which button was clicked and which to show up.
2) You can take a look at this link - DataGrid Sorting
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |