Anticipate rs.Update error?

Results 1 to 2 of 2

Thread: Anticipate rs.Update error?

  1. #1
    Join Date
    Dec 1969

    Default Anticipate rs.Update error?

    Why did the previous authour anticipate an error here as shown in the bottom half of this code? This is new to me, so any insight on this will be greatly appreciated.<BR><BR>&#039We need to update seperate table tblUsers with UserType and Password, which may have been switched<BR> sTempStr = Trim(Request.Form("txtInstitutionCode")) & "-" & Trim(Request.Form("txtMemberID"))<BR> sSql = "Select * From tblUsers Where UserName = &#039" & sTempStr & "&#039"<BR> rs.Open sSql, DbConn, 1, 3, 1<BR> rs("UserType") = Request.Form("lstUserType")<BR> rs("Password") = Trim(Request.Form("txtPassword"))<BR> rs.Update<BR><BR> If DbConn.Errors.Count &#062; 0 Then<BR> rs.Close<BR> DbConn.Close<BR> <BR> sTempStr = "Error occurred while attempting to update institution member information: "<BR> For Each Error in DbConn.Errors <BR> sTempStr = sTempStr & ": [" & Error.Number & "] " & Error.Description %&#062;<BR> &#060;script language="javascript"&#062;<BR> alert("&#060;% = sTempStr %&#062;");<BR> history.back()<BR> &#060;/script&#062;&#060;%<BR> Next<BR> Response.Flush<BR> Else<BR> rs.Close<BR> DbConn.Close <BR>%&#062;<BR>&#060;script language="javascript"&#062;<BR> alert("Member information was successfully updated.");<BR> history.go(-3);<BR>&#060;/script&#062;<BR>&#060;%<BR> End If<BR>%&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Anticipate rs.Update error?

    If there&#039s no match in the select, you have an immediate rs.EOF and trying to set field values will generate an error. Is the assumption that all institutions are already entered. If not, why not do something like this...<BR><BR>rs.Open sSql, DbConn, 1, 3, 1<BR>if (rs.EOF) then rs.Addnew<BR>rs("UserType") = Request.Form("lstUserType")<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts