Ask a Question related to ASP Database, Design and Development.
-
rey #1
change/swap order of two records in access
How can I efficiently swap order of two records sorted by an autonumber.
Access db. Primary key is an autonumber. I'm given a record ID corresponding
with the primary key.
I need to swap all record content of that record ID with either the previous
record or next record.
My first thoughts (of a novice mind you) are to select the two records in
one query and temporary hold
the content in variables or an array, and then update each record with said
variables/array using some for loop.
Can I select two or more records within a number range in one query?
Can I select, temporarily store, and loop update in one open
connection/execute? (I may be confusing terms in this question, I don't mean
the initial connection to db)
Any suggestion how to tackle this?
Thanks,
Rey
rey Guest
-
swap the reading order in a PDF
hi, is it possible to change the reading order in a PDF. 1. i want to change reading order 1 to 2 and 2 to 1. 2. so when i will save it as XML... -
Where can I change/swap an image file in director
I need to make some updates on a director project and I am very novice with the director. I have defined Photoshop as the external editors for jpg... -
Updating records in order (into an order)
I'm storing questions for a user-defined quiz. I can store them in the order they are entered without any problem. But... The user needs to have... -
Records in Ascending Order
I am using Dreamwaver MX 6.1 with PHP and a MySQL database. I have a page that displays upcoming events and they are arranged by date in ascending... -
swap values between records
CREATE TABLE Sometable (keycol CHAR(1) PRIMARY KEY, colx INTEGER NOT NULL) INSERT INTO Sometable VALUES ('a',1) INSERT INTO Sometable VALUES... -
rey #2
Re: change/swap order of two records in access
Note, primary key may not be consecutive due to deletions.
Thanks,
Rey
rey Guest
-
Ray at #3
Re: change/swap order of two records in access
While I'm curious as to why you need to do this, I guess it's not my
concern. Here's one way, that is pretty much what you were saying.
YourConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\path\file.mdb;"
Dim oADO, oRS1, oRS2
Dim iRec1, iRec2
iRec1 = 1
iRec2 = 2
Set oADO = Server.CreateObject("ADODB.Connection")
oADO.Open YourConnectionString
Set rs = oADO.Execute("SELECT [ID],[SomeData] FROM [SomeTable] WHERE [ID]
IN (" & iRec1 & "," & iRec2 & ") ORDER BY [ID]")
If Not rs.EOF Then
aVals = rs.GetRows()
rs.Close : Set rs = Nothing
oADO.Execute "UPDATE [SomeTable] SET [SomeData]='" & aVals(1,0) & "' WHERE
[ID]=" & aVals(0,1)
oADO.Execute "UPDATE [SomeTable] SET [SomeData]='" & aVals(1,1) & "' WHERE
[ID]=" & aVals(0,0)
End If
oADO.Close
Set oADO = Nothing
If you use a method such as this, you should read this.
[url]http://www.asp101.com/articles/chris/asptransactions/default.asp[/url]
Ray at home
"rey" <dojocre8@yahoo.com> wrote in message
news:cf6dnUm7Jbpn5TCiRVn-jw@comcast.com...corresponding> How can I efficiently swap order of two records sorted by an autonumber.
>
> Access db. Primary key is an autonumber. I'm given a record IDprevious> with the primary key.
> I need to swap all record content of that record ID with either thesaid> record or next record.
>
> My first thoughts (of a novice mind you) are to select the two records in
> one query and temporary hold
> the content in variables or an array, and then update each record withmean> variables/array using some for loop.
>
> Can I select two or more records within a number range in one query?
> Can I select, temporarily store, and loop update in one open
> connection/execute? (I may be confusing terms in this question, I don't> the initial connection to db)
>
> Any suggestion how to tackle this?
>
> Thanks,
> Rey
>
>
>
>
Ray at Guest



Reply With Quote

