Wrox Programmer Forums
|
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
 
Old August 8th, 2004, 05:57 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old August 8th, 2004, 08:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old August 9th, 2004, 01:17 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


 
Old August 9th, 2004, 09:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i add constraint on update cascade without mahen_pali SQL Server 2005 1 May 3rd, 2008 03:28 PM
Update Query to add a count of +1 melkin Classic ASP Databases 3 August 7th, 2007 11:59 AM
Best Practice for extra data under GridView rows SeanKilleen ASP.NET 2.0 Basics 0 July 19th, 2007 12:51 PM
Add, update and deletes.. crabjoe Classic ASP Basics 20 March 6th, 2007 09:07 PM
del+ins as opposed to update sspike SQL Server 2000 2 July 8th, 2004 06:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.