Multiple Update from text fields

Discussion in 'ASP General' started by Roy Adams, Jun 4, 2004.

  1. Roy Adams

    Roy Adams Guest

    Hello people I've recently been woring with multiple insert from text
    fields and got that woking fine thanks to the help from people from
    this forum
    now i'm trying to deal with multiple update, I'm pretty much using the
    same script but it isn't working properly
    I have a text field in a form with a text field called color, in a
    repeated region, that shows the amount of colours for the item that
    your viewing
    it submits to another page that handles spliting the querystring
    putting it into an array and looping through them.
    It does update all the records that have the same productID value but,
    only with the last item in the array if the last text field contains
    the value red it updates all fields with red that have the productID
    of 32
    here's the code
    maybe the problem could be with my sql statement

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <!--#include file="../../Connections/conn.asp" -->
    <%

    var colorForm = String(Request.Form("color"));//get the form field and
    put into var
    colorForm = colorForm.replace(/'/g, "''");
    colorForm_array = colorForm.split(",");//split at ","

    if( colorForm !="undefined" ){
    for( i=0 ; i < colorForm_array.length ; i ++){// loop through the
    array


    conn = Server.CreateObject('ADODB.Command');
    conn.ActiveConnection = MM_conn_blenz_STRING;

    conn.CommandText = ("UPDATE color SET color='" + colorForm_array +
    "' WHERE ProductID = 32" )

    conn.Execute();
    conn.ActiveConnection.Close();

    }
    }
    Response.Redirect("UpdateMenu.asp?ProductID=32&uc=1");





    %>
     
    Roy Adams, Jun 4, 2004
    #1
    1. Advertising

  2. Roy,

    First of all, what are you trying to do? Second, what does your table color
    look like? From what you showed, a sample SQL string could be

    UPDATE color SET color = 'White' WHERE ProductID = 32

    This updates ALL records that have ProductID of 32. Therefore, the last such
    SQL statement overrides all the ones before. You might want to have
    additional WHERE conditions, something like:

    UPDATE color SET color = 'White' WHERE ProductID = 32 AND ColorID = 55

    Where 55 is dynamic.

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Roy Adams" <> wrote in message
    news:...
    > Hello people I've recently been woring with multiple insert from text
    > fields and got that woking fine thanks to the help from people from
    > this forum
    > now i'm trying to deal with multiple update, I'm pretty much using the
    > same script but it isn't working properly
    > I have a text field in a form with a text field called color, in a
    > repeated region, that shows the amount of colours for the item that
    > your viewing
    > it submits to another page that handles spliting the querystring
    > putting it into an array and looping through them.
    > It does update all the records that have the same productID value but,
    > only with the last item in the array if the last text field contains
    > the value red it updates all fields with red that have the productID
    > of 32
    > here's the code
    > maybe the problem could be with my sql statement
    >
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    > <!--#include file="../../Connections/conn.asp" -->
    > <%
    >
    > var colorForm = String(Request.Form("color"));//get the form field and
    > put into var
    > colorForm = colorForm.replace(/'/g, "''");
    > colorForm_array = colorForm.split(",");//split at ","
    >
    > if( colorForm !="undefined" ){
    > for( i=0 ; i < colorForm_array.length ; i ++){// loop through the
    > array
    >
    >
    > conn = Server.CreateObject('ADODB.Command');
    > conn.ActiveConnection = MM_conn_blenz_STRING;
    >
    > conn.CommandText = ("UPDATE color SET color='" + colorForm_array +
    > "' WHERE ProductID = 32" )
    >
    > conn.Execute();
    > conn.ActiveConnection.Close();
    >
    > }
    > }
    > Response.Redirect("UpdateMenu.asp?ProductID=32&uc=1");
    >
    >
    >
    >
    >
    > %>
     
    Manohar Kamath [MVP], Jun 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. call_me_anything
    Replies:
    4
    Views:
    469
    Pete Becker
    Sep 30, 2007
  2. HockeyFan

    dropdownlist multiple fields in text?

    HockeyFan, Jul 28, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    152
  3. JP SIngh
    Replies:
    5
    Views:
    271
    Bob Barrows [MVP]
    Jan 24, 2006
  4. Replies:
    1
    Views:
    108
    Robert La Ferla
    Jul 4, 2007
  5. Replies:
    0
    Views:
    292
Loading...

Share This Page