ASP如何用数组成员作为变量名?
uid="xiaowang"pwd="123"arr=split("uid,pwd",",")rs.open"select*fromuserid",conn,3,2rs....
uid="xiaowang"
pwd="123"
arr=split("uid,pwd",",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=lbound(arr) to ubound(arr)
rs(""&arr(i)&"")=arr(i)
next
rs.update
rs.close
这样的实现结果是,将变量名uid,pwd作为值写到数据库了,请问如何将变量名uid,pwd的【值】写到数据库中同名字段中?
前一二楼只是把值得出了,却没有实现把值写数据库中【同名】字段下。 展开
pwd="123"
arr=split("uid,pwd",",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=lbound(arr) to ubound(arr)
rs(""&arr(i)&"")=arr(i)
next
rs.update
rs.close
这样的实现结果是,将变量名uid,pwd作为值写到数据库了,请问如何将变量名uid,pwd的【值】写到数据库中同名字段中?
前一二楼只是把值得出了,却没有实现把值写数据库中【同名】字段下。 展开
3个回答
展开全部
通过eval()函数获取变量值,代码如下:
uid="xiaowang"
pwd="123"
arr=split("uid,pwd",",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=lbound(arr) to ubound(arr)
rs(""&arr(i)&"")=eval(arr(i))
next
rs.update
rs.close
实例代码如下:
uid="xiaowang"
pwd="123"
arr=split("uid,pwd",",")
for i=lbound(arr) to ubound(arr)
response.Write(arr(i)&"="&eval(arr(i))&"<br>")
next
显示结果:
uid=xiaowang
pwd=123
uid="xiaowang"
pwd="123"
arr=split("uid,pwd",",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=lbound(arr) to ubound(arr)
rs(""&arr(i)&"")=eval(arr(i))
next
rs.update
rs.close
实例代码如下:
uid="xiaowang"
pwd="123"
arr=split("uid,pwd",",")
for i=lbound(arr) to ubound(arr)
response.Write(arr(i)&"="&eval(arr(i))&"<br>")
next
显示结果:
uid=xiaowang
pwd=123
展开全部
你上面赋值给数组的时候就搞错了..
arr=split(uid &","& pwd,",")
arr=split(uid &","& pwd,",")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
uid="xiaowang"
pwd="123"
arr=split(uid &","& pwd,",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=0 to ubound(arr)
rs(""&arr(i)&"")=arr(i)
next
rs.update
rs.close
pwd="123"
arr=split(uid &","& pwd,",")
rs.open "select * from userid",conn,3,2
rs.addnew
for i=0 to ubound(arr)
rs(""&arr(i)&"")=arr(i)
next
rs.update
rs.close
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询