I have a problem..

Results 1 to 2 of 2

Thread: I have a problem..

  1. #1
    Join Date
    Dec 1969

    Default I have a problem..

    .. with this code. It was Inserting a NEW record every time I ran a form update on that member. I took out the line rs.AddNew,<BR>I changed the cursor type from 1 to 0 and it works. But now it is not updating the records. There are about 10 records for the same Member now. Is not updating because it does not know which record to update?<BR><BR> &#039Need to update tblUsers with UserType and password, which may have been switched<BR> <BR> sTempStr = sInstitutionCode & "-" & Trim(Request.Form("txtMemberCode"))<BR> sSql = "Select * From tblUsers Where MemberID = &#039" & sTempStr & "&#039"<BR> rs.Open sSql, DbConn, 0, 3<BR> rs("MemberID") = sTempStr<BR> rs("UserType") = Trim(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 %&#062;<BR> &#060;script language="javascript"&#062;<BR> alert("Member information was successfully updated.");<BR> history.go(-3);<BR> &#060;/script&#062;&#060;%<BR> End If<BR>%&#062;<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default A couple of maybes...

    (1) You are re-setting the rs("MemberID") field that you used to SELECT the field with. I wouldn&#039t be suprised if the ADO driver interpreted this to mean "I need a new record with that same value" instead of "these are changes to the old record." There is *NO REASON* to try to change that field, so omit that statement!<BR><BR>(2) Try using a 3 instead of a 0 for the cursor type. I doubt this is the problem, but...<BR><BR>(3) You really ought to specify "no duplicates allowed" for the member id field in that table! You don&#039t want accidents (such as what has been happening to you) to create multiples with the same ID. You might get errors if you don&#039t allow duplicates, but at least the table won&#039t be corrupted.<BR><BR>LET ME KNOW! I&#039m curious which of the above helps, if any!<BR><BR>**************<BR><BR>sTempStr = sInstitutionCode & "-" & Trim(Request.Form("txtMemberCode"))<BR>sSql = "Select * From tblUsers Where MemberID = &#039" & sTempStr & "&#039"<BR>rs.Open sSql, DbConn, 3, 3<BR>&#039 $$$ KILL THIS LINE rs("MemberID") = sTempStr $$$ !!!<BR>rs("UserType") = Trim(Request.Form("lstUserType"))<BR>rs("Password" ) = Trim(Request.Form("txtPassword"))<BR>rs.Update<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