Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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 February 12th, 2004, 11:01 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Can I Update Multiple Records

Hi there

I was wondering if somebody could help me with the following problem. I am using ASP and SQL Server.

I have a table in SQl Server which contains product information. One of the columns is called OrderNo and is an int field. On my simple update page the administrator chooses a value for OrderNo (ranging from 1st to 10th, or 1 to 10) and on the front end the recordset is ordered by this OrderNo field. So, the product with OrderNo=1 will display first, then OrderNo=2 etc. This is OK but when I add a new record to the database using my insert page, I then have to change the Order of all the records in the database.

What I would like to do is this:
Have a results page which contains all records in my database, and in the column for OrderNo, have a dropdown box in each record. I can then change the order of all the products from this one page and then click on one update button which would update all the records accordingly.

BUT, I don't know how to write the stored procedure/ASP to go this.

Can anyone help me out?

Thanks in advance

Lucy

 
Old February 12th, 2004, 03:12 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why not use a query that utilizes a sort?? The order of entry into the data table is irrelevant...the query will look at the data and sort it for you...that is precisely the type of function a query is designed to perform

John

 
Old February 25th, 2004, 05:54 AM
Authorized User
 
Join Date: Feb 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the new product slots in and just bumps the other up, then why not just set the order for the item you are adding and before you do an insert update all the order fields, for entries whose order field is greater than or equal to the one you are adding, by adding 1 therefore shifting all the orders up one, then dot eh insert.

so if you were adding an item at 3rd in the order you would first of all update all the products which had an order number of 3 or above by adding 1 to them and then you would insert the new one at order position 3.

 
Old March 18th, 2004, 03:19 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kbrown2974
Default

OrderNo is the number of items? If that is what it is used for, you should use another field such as trackno to use for the query and sort on that. Whenever you want to add a new order, increase the the trackno by 1...example:

cmd = "select max(trackno) AS Lasttix FROM dbfname"
set rs = cn.Execute ( cmd )
Nexttix = rs("Lasttix") + 1






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Multiple Records cancer10 Classic ASP Databases 0 October 25th, 2006 01:01 AM
update multiple records mateenmohd Classic ASP Basics 4 June 28th, 2004 03:38 AM
update multiple records (solved) dhaywirex Classic ASP Databases 2 February 24th, 2004 12:23 AM
auto-update multiple records in subform stoneman Access 1 February 8th, 2004 12:19 AM
Update or add multiple table records rosenzl VB.NET 3 June 12th, 2003 01:59 PM





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