I am using the following code to split/join values in a multi-select
field. It is combining all the values in All the records into one long
string in each record in recordset.
Example: I have a recordset with 2 records.
The 1st contains the split/joined values: Alan Smir, Jeff Karl
The 2nd contains the value: Keith Robb
When it updates database, it will put Alan Smir, Jeff Karl, Keith Robb
into each record in the recordset
Instead it should be putting Alan Smir, Jeff Karl into the 1st record
and Keith Robb into the 2nd record in the recordset.
Does anyone see what is wrong with the code?
<% strID = split(request.f orm("Proj"), ", ")
mdgarray1 = split(request.f orm("mgrgroup") , ",")
redim mdgarray2(uboun d(mdgarray1))
for i = 0 to ubound(mdgarray 1)
mdgarray2(i) = Split(mdgarray1 (i)," - ")(0)
next
mgrgrp = Join(mdgarray2, ", ")
FOR i = LBound(strID) TO UBound(strID)
mySQL = "UPDATE ERoj SET mgrgroup= '" & trim(mgrgrp) & "' where (id ='"
& strID(i) & "')"
dbRoj.Execute(m ySQL)
NEXT
%>
Feb 14 '06
11 12624
pmarisole wrote: I did as you suggested and it works just great. I really appreciate you help with this.
Cool.
Come back someday and ask about using parameters. Dynamic sql is prone to
security problems (sql injection).
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Ok I am trying to split the mgrgroup field to extract the MD codes. I
got it to extract the codes and put them in the MDGroup field, but only
if all the records in the recordset are changed. If only one record is
changed while looping then it puts bogus names in the MDGroup. I'm not
sure how to make it overlook the MDGroup field if it is not changing.
Here's the code and the output is at the bottom of this message
if len(request.for m("Proj"))> 0 then
for each strID in request.form("P roj")
mgrgrp=""
mdgrp=""
if len(request.for m("mgrgroup_" & strID)) > 0 then
Redim arMgrs(request. form("mgrgroup_ " & strID).Count -1)
i = 0
for each strMgr in request.form("m grgroup_" & strID)
arMgrs(i)=RTrim (split(strMgr,"-")(0))
i = i + 1
next
mgrgrp=Join(arM grs,", ")
Redim arMds(request.f orm("mgrgroup_" & strID).Count -1)
i = 0
for each strMd in request.form("m grgroup_" & strID)
arMds(i)= right(split(str Md,",")(0), 5)
i = i + 1
next
mdgrp=Join(arMd s,",")
end if
mySQL = "UPDATE EBSProjects SET mgrgroup= '" & trim(mgrgrp) & "',
mdgroup= '" & trim(mdgrp) & "' where (ebsrefid ='" & strID & "')"
Response.Write mySQL & "<br>"
dbProject.Execu te(mySQL)
next
response.end
end if
*************** *************** *************** *** OUTPUT
*************** *************** ***************
THIS 1ST RECORD OF THE RECORDSET IS CHANGED
The MGRGROUP field contains:
Ashley Calvert - RTB1, Chris Gibney - TPP7
The MdGROUP field contains:
RTB1, TPP7
The SQL StatementUPDATE EBSProjects SET mgrgroup= 'Ashley Calvert,
Chris Gibney', mdgroup= 'RTB1, TPP7' where (ebsrefid ='60633400')
THIS IS THE 2ND RECORD IN THE RECORDSET AND IT DOES NOT CHANGE BUT IT
WRITES OVER THE RTB2 THAT IS IN THE FIELD FROM THE FIRST TIME IT WAS
CHANGED
The MGRGROUP field contains:
Alan Sanders
The MdGROUP field contains:
nders
The SQL StatementUPDATE EBSProjects SET mgrgroup= 'Alan Sanders',
mdgroup= 'nders' where (ebsrefid ='60691908')
It correctly adds the MdGroup code (RTB1, RBT2 etc) when the record is
modified but in a mass update, that particular record does not need to
be changed and it will overwrite the correct value in the MdGroup field
with 5 characters of the mgr name. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carlos Ribeiro |
last post by:
Hi all,
While writing a small program to help other poster at c.l.py, I found
a small inconsistency between the handling of keyword parameters of
string.split() and the split() method of strings. I wonder if someone
else had ever stumbled on it before, and if it has a good reason to
work like it is.
Both implementations take two parameters: the separator character and
the max number of splits (maxsplit). However, string.split() accept
|
by: Reb |
last post by:
Hi,
I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");
Thanks
Reb
|
by: Mike P |
last post by:
I am using Split to split get a number of items from a multi line text
box. But I need to be able to get the number of elements within the
text box (e.g. if the text box has 2,4,8 in it, I want to be able to
count that this text box has 3 elements entered into it). My code is
below :
for (int p=0; p < dgNational.Items.Count; p++)
{
strQuantity =
((TextBox)dgNational.Items.FindControl("txtAccount")).Text +"\r\n";
|
by: Christine |
last post by:
My code has a split function that should split the text file of numbers.
I've run this in previous programs as it is here and it worked, but now it
wont work for some reason and returns System_String. I don't see a
difference in the previous code and what I have now. Can anyone find where I
went wrong? Thanks a bunch!
//Open new stream reader and writer to read in file
//And write to a new file.
StreamWriter swa=new...
|
by: mannyGonzales |
last post by:
Hey guys,
Very common task: read a csv file. My data reads as:
"1","2","3",
my code reads this way:
While filename.Peek > -1
instr = filename.ReadLine
indata = Split(instr, ",")
| |
by: amitsoni.1984 |
last post by:
Hi,
I have to write a code in python to read a matrix from a text file and
for that i am using following code. But it gives an error saying
"NameError: name 'split' is not defined". Can anyone help me with this.
-------------------------------------------------
#!/usr/bin/python
import numpy
file = open('matrix.txt', 'r')
|
by: grey15 |
last post by:
hi to all......am very new to perl....so dnt knw much abt it....
i have a txt file.....so i have to split the values using delimiters.eg have following text-
Colombian|The finest Colombian beans, low flame roasted to yield a rich flavour.|7.99|
but when i use the split function using '|' as delimiter, it gives me errors-
use of uninitialized value in concatenation (.) or string
i used the following function
split(/|/,$_);
|
by: John |
last post by:
Hi
I have written a Split function which in turn calls the standard string
split function. Code is below;
Function Split1(ByVal Expression As String, Optional ByVal Delimiter As
String = " ", Optional ByVal Limit As Integer = -1, Optional ByVal Compare
As CompareMethod = CompareMethod.Binary, Optional ByVal MaxLength As Integer
= 0) As String()
|
by: nagmvs |
last post by:
Can anyone tell me about the usage of split function in Asp with Example ?
i done one project using split function.and i have some problems regarding storing data in data base.I use there variables.the data in the two variables is stored correctly.But the third variable data is stored some where. So please tell me some different tech. oh using split function in ASP using VB.NET.
thanks,
|
by: fellya |
last post by:
Hi,
i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python.
I've tried to write a simple program that can display a sentence. now my problem is how to write a code using split function to split that sentence into words then print out each word separately. let me give u an example:
>>>sentence=" My question is to know how to write a code in Python"
then the output of this...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |