使用Vbscript“SPLIT”多选字段上的功能 [英] Using Vbscript "SPLIT" function on Multi-select field

查看:65
本文介绍了使用Vbscript“SPLIT”多选字段上的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在多选

字段中拆分/加入值。它将所有记录中的所有值组合成记录集中每条记录中的一个长

字符串。


示例:我有一个包含2条记录的记录集。

第一个包含拆分/加入值:Alan Smir,Jeff Karl

第二个包含值:Keith Robb


当它更新数据库时,它会将Alan Smir,Jeff Karl,Keith Robb

放入记录集中的每条记录中

相反应该将Alan Smir,Jeff Karl放入第一张唱片

和Keith Robb进入唱片集的第二张唱片。

有没有人看到代码有什么问题?


<%strID = split(request.form(" Proj"),",")

mdgarray1 = split(request.form(" mgrgroup"),"," ;)

redim mdgarray2(ubound(mdgarray1))

for i = 0 to ubound(mdgarray1)

mdgarray2(i)= Split( mdgarray1(i)," - ")(0)

next

mgrgrp =加入(mdga rray2,",")


FOR i = LBound(strID)TO UBound(strID)

mySQL =" UPDATE ERoj SET mgrgroup =' " &安培;修剪(mgrgrp)& "''where(id =''"

& strID(i)&"'')"

dbRoj.Execute(mySQL)

NEXT

%>

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.form("Proj"), ", ")
mdgarray1 = split(request.form("mgrgroup"), ",")
redim mdgarray2(ubound(mdgarray1))
for i = 0 to ubound(mdgarray1)
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(mySQL)
NEXT
%>

推荐答案

pmarisole写道:
pmarisole wrote:
我使用以下代码在多选
字段中拆分/连接值。它将所有记录中的所有值组合成记录集中每条记录中的一个长字符串。

示例:我有一个包含2条记录的记录集。
第1个包含分裂/加入价值观:Alan Smir,Jeff Karl
第二个包含价值:Keith Robb

当它更新数据库时,它会让Alan Smir,Jeff Karl,Keith Robb
记录集中的每条记录相反,它应该是让Alan Smir,Jeff Karl进入第一记录和Keith Robb进入记录集的第二记录。
有没有人看到有什么问题?代码?
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?




并非没有看到结果:

Response.Write request.form(" Proj")& "< BR>"

Response.Write request.form(" mgrgroup")& "< BR>"


另外,向我们展示您希望此代码生成的两个SQL语句以及

执行。


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



Not without seeing the result of :
Response.Write request.form("Proj") & "<BR>"
Response.Write request.form("mgrgroup") & "<BR>"

Also, show us the two SQL statements you wish this code to generate and
execute.

--
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.


第一记录值

Alan Smir,Jeff Karl

第二记录值

Keith Robb


response.write mgrgrp

response.write" ;< br>"

response.write strID(i)

response.end


这是来自的输出两个记录的response.write

Alan Smir,Jeff Karl,Keith Robb(它将所有值中的所有值组合成两个记录为一个值)
60691908(这是循环中的第一个strID)


这是我用来更新数据库的SQL语句

FOR i = LBound(strID)TO UBound(strID)

mySQL =" UPDATE ERoj SET mgrgrp =''" &安培;修剪(mgrgrp)& "''where(id =''"

& strID(i)&"'')"

dbRoj.Execute(mySQL)

NEXT

1st Record Value
Alan Smir, Jeff Karl
2nd Record Value
Keith Robb

response.write mgrgrp
response.write "<br>"
response.write strID(i)
response.end

This is the output from response.write for the two records
Alan Smir, Jeff Karl, Keith Robb (it''s combining all the values in
both records into ONE VALUE)
60691908 (this is the 1st strID in the loop)

This is the SQL statement that I am using to update the database
FOR i = LBound(strID) TO UBound(strID)
mySQL = "UPDATE ERoj SET mgrgrp= ''" & trim(mgrgrp) & "'' where (id =''"
& strID(i) & "'')"
dbRoj.Execute(mySQL)
NEXT


pmarisole写道:
pmarisole wrote:
第一记录值
Alan Smir,Jeff Karl
第二记录价值
Keith Robb


是的,你在第一条消息中说了这个。这不是一个有效的声明,但我

让它通过(记录包含字段 - 你没有向我显示任何字段名称)

response.write mgrgrp
response.write"< br>"
response.write strID(i)
response.end


你为什么要告诉我这个?我没有要求看到它。

请再次阅读我的回复。我要求查看结果:


Response.Write request.form(" Proj")& "< BR>"

Response.Write request.form(" mgrgroup")& < BR>"


实际上,运行此代码:


Response.Write" request.form(" Proj包含:< BR>"

Response.Write request.form(" Proj")& "< BR>"

Response.Write" request.form("" mgrgroup"")包含:< BR>"

Response.Write request.form(" mgrgroup")& "< BR>"


并告诉我结果。

这是来自response.write的两个记录的输出
Alan Smir,Jeff Karl,Keith Robb(它将两个记录中的所有值组合成一个值)


嗯,这是一个线索,发生了什么事,不是吗?

60691908(这是循环中的第一个strID)

这是我用来更新的SQL语句数据库
1st Record Value
Alan Smir, Jeff Karl
2nd Record Value
Keith Robb
Yes, you said this in your first message. It is not a valid statement, but I
let it pass (records contain fields - you have not shown me any field names)

response.write mgrgrp
response.write "<br>"
response.write strID(i)
response.end
Why are you showing me this? I did not ask to see it.
Please read my reply again. I asked to see the result of:

Response.Write request.form("Proj") & "<BR>"
Response.Write request.form("mgrgroup") & "<BR>"

In fact, run this code:

Response.Write "request.form(""Proj"") contains:<BR>"
Response.Write request.form("Proj") & "<BR>"
Response.Write "request.form(""mgrgroup"") contains:<BR>"
Response.Write request.form("mgrgroup") & "<BR>"

and show me that result.

This is the output from response.write for the two records
Alan Smir, Jeff Karl, Keith Robb (it''s combining all the values
in both records into ONE VALUE)
Well, that''s one clue as to what is going on, isn''t it?
60691908 (this is the 1st strID in the loop)

This is the SQL statement that I am using to update the database




不,不是。这是一系列vbscript语句,应该是
生成要执行的sql语句。


Bob Barrows


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



No, it is not. This is the series of vbscript statements that is supposed to
generate the sql statements to be executed.

Bob Barrows

--
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.


这篇关于使用Vbscript“SPLIT”多选字段上的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆