Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Multiple Update from text fields

Reply
Thread Tools

Multiple Update from text fields

 
 
Roy Adams
Guest
Posts: n/a
 
      06-04-2004
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[i] +
"' WHERE ProductID = 32" )

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

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





%>
 
Reply With Quote
 
 
 
 
Manohar Kamath [MVP]
Guest
Posts: n/a
 
      06-04-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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[i] +
> "' WHERE ProductID = 32" )
>
> conn.Execute();
> conn.ActiveConnection.Close();
>
> }
> }
> Response.Redirect("UpdateMenu.asp?ProductID=32&uc= 1");
>
>
>
>
>
> %>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print struct fields and its member structs' fields recursively, generically call_me_anything C++ 4 09-30-2007 10:12 PM
associating an array to multiple text fields in a form robertlaferla@comcast.net Ruby 1 07-04-2007 03:38 AM
dropdownlist multiple fields in text? HockeyFan ASP .Net Web Controls 1 07-31-2006 06:21 AM
Search for Multiple keywords in multiple fields JP SIngh ASP General 5 01-24-2006 01:53 PM
Netscape hidden fields - array - multiple fields with same name mark.reichman@rl.af.mil Javascript 0 07-17-2003 03:05 PM



Advertisments