如何将数据库检索出来的数据组合新的数组

lonan 2009-07-18 01:09:57
如何将数据库检索出来的数据组合新的数组
Dim Mobile,RS2
SqlStr="Select UserID,GroupID,UserName,Mobile From User where Locked=0 and GroupID=15 Order By UserID"
Set RS2=Server.CreateObject("ADODB.RECORDSET")
RS2.Open SqlStr,Conn,1,1
IF RS2.Eof And RS2.Bof Then
Mobile=""
Else
????????????????????????????????????

我需要将符合条件的会员电话号码组合成一个新的用逗号隔开的数组,如:
13588888888,13655555555,13155554444,13288888888


请教一下,问号处的循环检索语句怎样整???

...全文
103 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2009-07-18
  • 打赏
  • 举报
回复
【我需要将符合条件的会员电话号码组合成一个新的用逗号隔开的数组】:
你这样说就让人误会你需要一个新数组了,应该说是“我需要将符合条件的会员电话号码组合成一个新的号码字串”,呵呵
lonan 2009-07-18
  • 打赏
  • 举报
回复
我是要将这个数组数据传送到JS里面进行发送手机短信,同时发送多个号码需要将逗号隔开,所以。。。。。
非常感谢您,搞定!!!!
toury 2009-07-18
  • 打赏
  • 举报
回复

<%
Dim Mobile,RS2
SqlStr="Select UserID,GroupID,UserName,Mobile From User where Locked=0 and GroupID=15 Order By UserID"
Set RS2=Server.CreateObject("ADODB.RECORDSET")
RS2.Open SqlStr,Conn,1,1
IF RS2.Eof And RS2.Bof Then
Mobile=""
Else
if Mobile ="" then
Mobile=rs2("Mobile")
else
Mobile=Mobile&","&rs2("Mobile")
end if
end if
response.write Mobile
%>
lzp4881 2009-07-18
  • 打赏
  • 举报
回复
Mobile1=Mobile1&Mobile(0,i)&","
其实Mobile已经是一个包含所有号码的数组了,你用得着再生成一次字符串吗?
lonan 2009-07-18
  • 打赏
  • 举报
回复
这样写 Mobile1=Mobile(0,i)&","
只有一个数据出来
出来的数据是:13711585678,
lzp4881 2009-07-18
  • 打赏
  • 举报
回复
Mobile已经是一个数组了,你试图把它变成一个字符串?你应该换个变量名
Mobile1=Mobile(0,i)&"," /错误处
lonan 2009-07-18
  • 打赏
  • 举报
回复
当我需要把Mobile这个数组变量值传递给下个函数,我这样写

Dim Mobile,RS2
SqlStr="Select UserID,GroupID,UserName,Mobile From User where Locked=0 and GroupID=15 Order By UserID"
Set RS2=Server.CreateObject("ADODB.RECORDSET")
RS2.Open SqlStr,Conn,1,1
IF RS2.Eof And RS2.Bof Then
Mobile=""
Else
Mobile = rs2.GetRows(,,"Mobile")
for i=0 to ubound(Mobile,2)
Mobile=Mobile(0,i)&"," /错误处
next
end if

会出现
Microsoft VBScript 运行时错误 (0x800A000A)
该数组为定长的或临时被锁定
Mobile=Mobile&","&Mobile(0,i)
这样写也不对

我需要将Mobile数组传递给下一个变量


lzp4881 2009-07-18
  • 打赏
  • 举报
回复
<%
Dim Mobile,RS2
SqlStr="Select UserID,GroupID,UserName,Mobile From User where Locked=0 and GroupID=15 Order By UserID"
Set RS2=Server.CreateObject("ADODB.RECORDSET")
RS2.Open SqlStr,Conn,1,1
IF RS2.Eof And RS2.Bof Then
Mobile=""
Else
Mobile = rs2.GetRows(,,"Mobile")
end if
%>
输出:
<%
for i=0 to ubound(Mobile,2)
response.write Mobile(0,i)&","
next
%>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧