I am using asp with an access database.
I have a column with "ListOrder" that specifies the order each announcement is placed in on the website. I want to automatically update this column each time there is a new entry, by increasing the list order by 1 for each entry that has a list order higher than the new entry (so, say I have a new entry with a list order of 3, I would like all announcements that have a list order of 3 or more to increase by 1 - so 3 moves down to 4, 4 moves down to 5 and so on)
Here is the code I'm using to update the colum. It returns no records, even though there are records higher than the new entry.
The code doesn't update the column either - what could I be doing wrong? the data type for the column is number - long integer. A previous version of code was returning "-1" records - and I'm not sure what that means. Sorry, if these are silly questions, I'm still learning!
thanks in advance!
'---------------
dim SQL_SelLorder, SQL_updateLorder, newLorderNo, rs2
newLorderNo = Request.Form("lorder")
SQL_SelLorder="SELECT * FROM MainNews WHERE ListOrder>=" & newLorderNo &""
On Error Resume Next
SQL_updateLorder = "UPDATE MainNews SET ListOrder=" & currentLorderNo & ""&_
"WHERE ID = " & id & ";"
On Error Resume Next
set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open SQL_SelLorder, sDATA_SOURCE
numRecords = 0
while not rs2.EOF
dim currentLorderNo, id
currentLorderNo=rs2("ListOrder")
id=rs2("id")
currentLorderNo = currentLorderNo + 1
SQL_updateLorder, sDATA_SOURCE
rs2.MoveNext()
WEnd
If numRecords = 0 Then
response.write("no records")
end if
Set rs2 = Nothing
'----------
I have a column with "ListOrder" that specifies the order each announcement is placed in on the website. I want to automatically update this column each time there is a new entry, by increasing the list order by 1 for each entry that has a list order higher than the new entry (so, say I have a new entry with a list order of 3, I would like all announcements that have a list order of 3 or more to increase by 1 - so 3 moves down to 4, 4 moves down to 5 and so on)
Here is the code I'm using to update the colum. It returns no records, even though there are records higher than the new entry.
The code doesn't update the column either - what could I be doing wrong? the data type for the column is number - long integer. A previous version of code was returning "-1" records - and I'm not sure what that means. Sorry, if these are silly questions, I'm still learning!
thanks in advance!
'---------------
dim SQL_SelLorder, SQL_updateLorder, newLorderNo, rs2
newLorderNo = Request.Form("lorder")
SQL_SelLorder="SELECT * FROM MainNews WHERE ListOrder>=" & newLorderNo &""
On Error Resume Next
SQL_updateLorder = "UPDATE MainNews SET ListOrder=" & currentLorderNo & ""&_
"WHERE ID = " & id & ";"
On Error Resume Next
set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open SQL_SelLorder, sDATA_SOURCE
numRecords = 0
while not rs2.EOF
dim currentLorderNo, id
currentLorderNo=rs2("ListOrder")
id=rs2("id")
currentLorderNo = currentLorderNo + 1
SQL_updateLorder, sDATA_SOURCE
rs2.MoveNext()
WEnd
If numRecords = 0 Then
response.write("no records")
end if
Set rs2 = Nothing
'----------