
asp 字符串连接变量
sql="selectsum(ordervalue)from[user]whereusername="setrs=server.createobject("adodb.r...
sql="select sum(ordervalue) from [user] where username="
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if not rs.eof then
dim i
i=0
do while not rs.eof
f_name=rs("username")
sql7="select sum(money) from [order] where f_name='"&f_name&"' and staute=1"
set rs7=conn.execute(sql7)
icount?=rs7(0) '想把i值连接在icount之后
rs7.close
set rs7=nothing
%>
金额:<%=icount?%> '想把i值连接在icount之后
<%
rs.movenext
loop
i=i+1
end if
rs.close
set rs=nothing
怎么处理?先谢谢大家
icount?=rs7(0) '想把i值连接在icount之后
意思:当i=1时 为icount1
当为2时,为icount2
<%=icount?%>这个和上面的意思一样 展开
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if not rs.eof then
dim i
i=0
do while not rs.eof
f_name=rs("username")
sql7="select sum(money) from [order] where f_name='"&f_name&"' and staute=1"
set rs7=conn.execute(sql7)
icount?=rs7(0) '想把i值连接在icount之后
rs7.close
set rs7=nothing
%>
金额:<%=icount?%> '想把i值连接在icount之后
<%
rs.movenext
loop
i=i+1
end if
rs.close
set rs=nothing
怎么处理?先谢谢大家
icount?=rs7(0) '想把i值连接在icount之后
意思:当i=1时 为icount1
当为2时,为icount2
<%=icount?%>这个和上面的意思一样 展开
2个回答
展开全部
只是要显示 i 还是怎么样?
显示 i :<%=i%>
不明白你怎么定义变量会有个问号的?
使用数组吧,这个问题会变得很容易.
把你的改成下面的:
<%
sql="select sum(ordervalue) from [user] where username="
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.recordcount>0 then
for i=1 to rs.recordcount
f_name=rs("username")
'''------------------------------------------------
''其实我不明你为何这里要这样,这可是很多次的打开数据库,又关闭.这很不好.
sql7="select sum(money) from [order] where f_name='"&f_name&"' and staute=1"
set rs7=conn.execute(sql7)
dim icount(rs7.recordcount)
icount(i)=rs7(0) '想把i值连接在icount之后
rs7.close
set rs7=nothing
%>
金额:<%=icount(i)%>
<%
rs.movenext
next
else
response.Write("nothing to show!!")
end if
'''---------------------------------------------------
rs.close
set rs=nothing
%>
显示 i :<%=i%>
不明白你怎么定义变量会有个问号的?
使用数组吧,这个问题会变得很容易.
把你的改成下面的:
<%
sql="select sum(ordervalue) from [user] where username="
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.recordcount>0 then
for i=1 to rs.recordcount
f_name=rs("username")
'''------------------------------------------------
''其实我不明你为何这里要这样,这可是很多次的打开数据库,又关闭.这很不好.
sql7="select sum(money) from [order] where f_name='"&f_name&"' and staute=1"
set rs7=conn.execute(sql7)
dim icount(rs7.recordcount)
icount(i)=rs7(0) '想把i值连接在icount之后
rs7.close
set rs7=nothing
%>
金额:<%=icount(i)%>
<%
rs.movenext
next
else
response.Write("nothing to show!!")
end if
'''---------------------------------------------------
rs.close
set rs=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询