Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update sort order in asp page

Posted on 2011-09-12
2
Medium Priority
?
319 Views
Last Modified: 2012-08-13
After a user uploads a photo for a gallery, i collect the file name and sort order in an Access database.  I have the sort order 0.  There are about 60 images in the table.  After the new record is added, i want to update the sort order for all the records, making the one i just added the one on top, so i'm using the following code.  It updates the record to "1" that i added as 0 and adds 1 to each succeeding record.  But the record that is "1" doesn't get updated but all the rest do.  so then i have 1, 1, 2, 3, etc.  Two number ones. What's up with that?  I've been jacking around with this, trying to refresh, even setting up another page to update the sort order separately.  Why would it add +1 to all of the records except the original #1?  What am i missing?  Thanks in advance.
Set rs2 = Server.CreateObject("ADODB.Recordset")
	Dim strTableName2
	strTableName2 = "xmlContents"
	rs2.Open strTableName2 & " WHERE xmlCatid=" & request.querystring("catid") & " order by xmlSortOrder", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
	rs2("xmlSortOrder")=rs2("xmlSortOrder") + 1
	rs2.Update

Open in new window

0
Comment
Question by:meldraper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 1000 total points
ID: 36529957
As per your code description it seems that you ADD the records first and later do the update, in which case when you ADD the new records whats the xmlSortOrder sequence does it start from 0 if that is the case you would run into this problem. Would suggest perform the update statement first, grab the MAX xmlSortOrder and later execute the insert statement adding order as MAX xmlSortOrder + 1.


Also please provide complete code sample to help you debug the issue.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 36530234
Update the sort order first.  Then insert the single record during which you set the value of xmlSortOrder to 0.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question