Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to change value in recordset field?
Message
From
17/06/2001 00:19:06
 
 
To
13/06/2001 15:22:07
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00519020
Message ID:
00520336
Views:
18
This message has been marked as the solution to the initial question of the thread.
Alex,
I might have found the solution to your problem...

The problem with updating the country "made up" field is that it does not exist on the table but only on the query, and ADO cannot update a non-existant field. Your best bet would be to add a country field to the table (or one of the tables) that makes up RS2, and then update it as you were doing.
Here's code that should work. Recordset rs2 has to be specifically created either with the OBJECT tag or with Server.CreateObject, otherwise you cannot specifically set the properties:
...
rs2.CursorLocation = 3 'adUseClient
rs2.CursorType = 0  'adOpenForwardOnly (default, and that's all you need)
rs2.LockType = 4  'adLockBatchOptimistic (see below)
...
rs2.Open "YOUR SQL STMT", conn 'conn is your active connection object
...
'do your update as needed
Do While Not rs2.EOF
 ...
 rs2.Fields("country").value = rs1("Country")
 rs.MoveNext
 ...
Loop

...do all the work you need to do with the new data in rs2

rs2.CancelBatch 'if you don't actually want to update the table.
If you don't use BatchOptimistic as your lock type, the "Country" field on the table in RS2 will be updated as you move from record to record. Even if you do want to update the table, this method involves one trip to the SQL server for each record (pretty expensive). If you want to update it, do it in batch. After you are done updating rs2, call rs2.UpdateBatch; this is one trip to update all records. Otherwise, simply do as shown above to cancel updates to the table (note that even if you don't call cancelBatch, the update won't be made unless you call UpdateBatch; this is just a re-assurance).

Hope it works for you.
Andres M. Chiriboga, MCSE, MCP+I
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform