- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have an sql table with fields (id, value1, value2)
id value1 value 2
1 5 10
2 23 12
3 34 23
4 22 24
what i need is to create a vbscript of similar style to the one below which will run through a loop and for each row will proceed as follows:
1. get values of current row (which will use to update next row)
2. update values of current row with values taken from previous record
3. move to next row and get values of current row
4. update values of current row with values in step1
5. add new record in the end with last data
the resulting values of table must be after loop:
id value1 value2
1 5 10
2 5 10
3 23 12
4 34 23
5 22 24
i = 0
dim old1, old2
old2 = 100
mysql2 = "SELECT value1, value2 FROM table1"
set rstemp2 = Server.CreateObject("ADODB
rstemp2.Open mysql2, conn, 1,2
do until rstemp2.eof
old1 = rstemp2.fields("value1").v
rstemp2.movenext
i = i + 1
loop
rstemp2.close
set rstemp2 = nothing
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Sharath_123Posted on 2009-04-10 at 17:17:05ID: 24120353
All you need is incremnt the ID by 1 and insert a record with minimum id. Why can't you try like this.
The LOOP is slower than the DML statements. So use UPDATE/INSERT statement to do this.
Let me know if you still looking for loop.
Select allOpen in new window