|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update Multiple Records
Hi,
I am trying to update multiple records in my database, but the code below doesn't seem to work correctly - how ever if I only update one record the code works correctly and updates the data. Updating 1 record (does work) ///////////////////////////////////////////////////////////// dim DLid2 DLid2=30 Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT Dlrsitename,Dlraddress FROM dealers WHERE Dealerid="&DLid2&"" rsUpdateEntry.CursorType = 2 rsUpdateEntry.LockType = 3 rsUpdateEntry.Open strSQL, Conn rsUpdateEntry.Fields("Dlraddress") = Request.Form("Dlraddress") rsUpdateEntry.Update rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set Conn = Nothing Response.write "done" Response.Redirect("default.asp?PageID=50") Updating 2 record (doesn't work) ///////////////////////////////////////////////////////////// dim DLid2 DLid2=30 Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT Dlrsitename,Dlraddress FROM dealers WHERE Dealerid="&DLid2&"" rsUpdateEntry.CursorType = 2 rsUpdateEntry.LockType = 3 rsUpdateEntry.Open strSQL, Conn rsUpdateEntry.Fields("DlrTown") = Request.Form("DlrTown") rsUpdateEntry.Fields("Dlraddress") = Request.Form("Dlraddress") rsUpdateEntry.Update rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set Conn = Nothing Response.write "done" Response.Redirect("default.asp?PageID=50") Does anyone know why? am I missing something? Thanks in advance! Allan |
|
#2
|
|||
|
|||
|
Maybe because in the second update you are trying to update your recordset with a field which is not selected:
Code:
rsUpdateEntry.Fields("DlrTown") = Request.Form("DlrTown")
you have not selected DlrTown in your recordset.
__________________
- Rogier Doekes |
|
#3
|
|||
|
|||
|
This is the ammended code - works fine!
dim DLid2 DLid2=30 Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT Dlrsitename,Dlraddress, DlrTown FROM dealers WHERE Dealerid="&DLid2&"" rsUpdateEntry.CursorType = 2 rsUpdateEntry.LockType = 3 rsUpdateEntry.Open strSQL, Conn rsUpdateEntry.Fields("DlrTown") = Request.Form("DlrTown") rsUpdateEntry.Fields("Dlraddress") = Request.Form("Dlraddress") rsUpdateEntry.Update rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set Conn = Nothing Response.write "done" Response.Redirect("default.asp?PageID=50") Any queries contact me ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Update Multiple Records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|