Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor move to the next after insert

Status
Not open for further replies.

xue

Programmer
Feb 5, 2001
12
0
0
US
I want to be able to add a record and move the cursor to the next, so every thing came after should alway add at the end. but with the code following, after I add my first record, rest of my records always add on top of my last record, so it is
2
3
4
5
6
1
anybody know how can I ask the cursor to move past the last record? thank you. my code:

Dim source
source = "SELECT * FROM Cart WHERE control= '" & strCONTROL & "' "
On Error Resume Next
rs.Open source, Connstring, adOpenDynamic, adLockOptimistic

Do until rs.EOF
rs.MoveNext
Loop

Response.Write "rs is EOF"
Set rs = conn.Execute("INSERT INTO Cart VALUES ('2/01/01','','" & strCONTROL & "' )")
 
You are updating your database with a SQL string (which is executed on the Connection, not on the recordset), so ASP doesn't care what you've done with your recordset.

If you want to add a record in a specific place, move your recordset to that place (like you did), and use rs.AddNew to insert a new record. Then do rs("field") = "value" to insert values into that new record.

At the end of your updating, do rs.Update to update your database.

If you run a SQL commant on the connection, ASP doesn't care what you did to the databse. It updates FIFO. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top