SQL Update

Results 1 to 2 of 2

Thread: SQL Update

  1. #1
    Join Date
    Dec 1969

    Default SQL Update

    I want to update the data in a table (ContactContactType table), but the code below is not passing either value into the array<BR><BR>Anyone have any ideas???<BR><BR>do while not rstConType.EOF<BR> strName = Request.form("ContactType_" & rTrim(rstConType.fields("ContactType")))<BR> strCheckbox = Request.form("ContactType_" & rTrim(rstConType.fields("ContactType")))<BR><BR> &#039;if null then set value to 0<BR> if (strCheckbox &#060;&#062; "1") then<BR> strCheckbox="0"<BR> end if<BR><BR> strHCheckbox = Request.form("HContactType_" & rTrim(rstConType.fields("ContactType")))<BR><BR> if (strCheckbox &#060;&#062; strHCheckbox) then<BR> if (strCheckbox &#060; strHCheckbox) then &#039; the checkbox was deselected<BR> &#039;SQL to delete record<BR> strSQLDel = "DELETE FROM ContactContactType WHERE ContactTypeID_fk = &#039;" & ContactTypeID & "&#039;"<BR> dbconn.Execute(strSQLDel)<BR> else &#039; the check box was selected<BR> &#039;SQL to insert record<BR> dim NewArray<BR> dim i<BR> NewArray = split(Request.Form(strHCheckbox), ", ")<BR> <BR> for i=0 to UBound(NewArray)<BR> strSQLAdd = "INSERT INTO ContactContactType(ContactTypeId_fk, ContactID_fk) VALUES (&#039;" & rtrim(NewArray(i)) & "&#039;,&#039;" & rtrim(ContactID) & "&#039;)"<BR> Response.Write ContactID<BR> Response.Write ContactTypeID<BR> dbconn.Execute(strSQLAdd)<BR> next<BR> <BR> end if &#039; end if - the checkbox was selected / deselected<BR><BR> end if &#039;end if - there is change in the checkbox<BR> rstConType.MoveNext <BR>loop

  2. #2
    Join Date
    Dec 1969

    Default Code makes no sense...

    Did you ever try DEBUGGING?<BR><BR>Like just before this line:<BR><BR> if (strCheckbox &#060;&#062; strHCheckbox) then<BR><BR>doing something such as:<BR><BR> Response.Write "strCheckBox=" & strCheckBox & ", strHCheckBox=" & strHCheckBox & "&#060;P&#062;"<BR><BR>???<BR><BR>Because later you try to split strHCheckBox, so you seem to think that it will be a comma delimited list. But strCheckBox is just a one-character string (yes, you made it a string, not a number).<BR><BR>Maybe you need to rethink the logic of this???<BR><BR>But learn to DEBUG DEBUG DEBUG.<BR><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