asp+access过程;变量 难问题!

sweilin 2007-11-27 07:14:20

<%
sub fun
dim s1
dim cup1
dim cdown1
dim i1
randomize
for i1=1 to 1
if rnd<0.5 then
s1=s1& "+"
cup1=cup1+1
else
s1=s1& "-"
cdown1=cdown1+1
end if
next
response.write(s1)


dim s2
dim cup2
dim cdown2
dim i2
randomize
for i2=1 to 1
if rnd<0.5 then
s2=s2&"+"
cup2=cup2+1
else
s2=s2&"-"
cdown2=cdown2+1
end if
next
response.write(s2)

dim s3
dim cup3
dim cdown3
dim i3
randomize
for i3=1 to 1
if rnd<0.5 then
s3=s3&"+"
cup3=cup3+1



else
s3=s3&"-"
cdown3=cdown3+1
end if
next
response.write(s3)


dim s,z1,z2,z3,z4,z5,z6

s=s1+s2+s3
z1=s



set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("gu.mdb")

exec="insert into sh1(name,z1)values('1','"+s+"')"
conn.execute exec
'end if


end sub

fun
%>
--------------------------------------
说明ACCESS库名gu.mdb,表sh1,表里字段name,z1,z2,z3,z4,z5,z6
3个随机数后写库存储,正如上面的那样,正确.

但如再执行5次上面的过程,
只是第二次要求往库里z2里写;同时要求往name里写2
...3次.....z3.....................3
...4次.........z4......................4
.....
......6次要求往库里z6里写.........................6
...全文
81 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinastorm 2007-11-27
  • 打赏
  • 举报
回复
用循环实现吧,这样做好麻烦的,先存到数组里,然后循环插入表中
sweilin 2007-11-27
  • 打赏
  • 举报
回复
要不能达到这种效果也可以:前6个过程,NAME里的数不要求变化,每次都是同样的值;只要求S值分别写进z1,z2,z3,z4,z5,z6里.;然后再来6个过程, NAME里的数这次要求加1; 同时S值分别写进z1,z2,z3,z4,z5,z6里 .
sweilin 2007-11-27
  • 打赏
  • 举报
回复
我上面写了3个过程,我想要6个这样的过程简化在一起.你看每次插入exec="insert into sh1(name,zN)values('M','"+s+"')"

M,N为不同的数.如每次M,N值一样,就很容易了.
sweilin 2007-11-27
  • 打赏
  • 举报
回复
<%
sub fun
dim s1
dim cup1
dim cdown1
dim i1
randomize
for i1=1 to 1
if rnd <0.5 then
s1=s1& "+"
cup1=cup1+1
else
s1=s1& "-"
cdown1=cdown1+1
end if
next
response.write(s1)


dim s2
dim cup2
dim cdown2
dim i2
randomize
for i2=1 to 1
if rnd <0.5 then
s2=s2&"+"
cup2=cup2+1
else
s2=s2&"-"
cdown2=cdown2+1
end if
next
response.write(s2)

dim s3
dim cup3
dim cdown3
dim i3
randomize
for i3=1 to 1
if rnd <0.5 then
s3=s3&"+"
cup3=cup3+1



else
s3=s3&"-"
cdown3=cdown3+1
end if
next
response.write(s3)


dim s,z1,z2,z3,z4,z5,z6

s=s1+s2+s3
z1=s



set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("gu.mdb")

exec="insert into sh1(name,z1)values('1','"+s+"')"
conn.execute exec
'end if


end sub

fun
%>
<%
sub fun
dim s1
dim cup1
dim cdown1
dim i1
randomize
for i1=1 to 1
if rnd <0.5 then
s1=s1& "+"
cup1=cup1+1
else
s1=s1& "-"
cdown1=cdown1+1
end if
next
response.write(s1)


dim s2
dim cup2
dim cdown2
dim i2
randomize
for i2=1 to 1
if rnd <0.5 then
s2=s2&"+"
cup2=cup2+1
else
s2=s2&"-"
cdown2=cdown2+1
end if
next
response.write(s2)

dim s3
dim cup3
dim cdown3
dim i3
randomize
for i3=1 to 1
if rnd <0.5 then
s3=s3&"+"
cup3=cup3+1



else
s3=s3&"-"
cdown3=cdown3+1
end if
next
response.write(s3)


dim s,z1,z2,z3,z4,z5,z6

s=s1+s2+s3
z2=s



set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("gu.mdb")

exec="insert into sh1(name,z2)values('2','"+s+"')"
conn.execute exec
'end if


end sub

fun
%>
<%
sub fun
dim s1
dim cup1
dim cdown1
dim i1
randomize
for i1=1 to 1
if rnd <0.5 then
s1=s1& "+"
cup1=cup1+1
else
s1=s1& "-"
cdown1=cdown1+1
end if
next
response.write(s1)


dim s2
dim cup2
dim cdown2
dim i2
randomize
for i2=1 to 1
if rnd <0.5 then
s2=s2&"+"
cup2=cup2+1
else
s2=s2&"-"
cdown2=cdown2+1
end if
next
response.write(s2)

dim s3
dim cup3
dim cdown3
dim i3
randomize
for i3=1 to 1
if rnd <0.5 then
s3=s3&"+"
cup3=cup3+1



else
s3=s3&"-"
cdown3=cdown3+1
end if
next
response.write(s3)


dim s,z1,z2,z3,z4,z5,z6

s=s1+s2+s3
z3=s



set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("gu.mdb")

exec="insert into sh1(name,z3)values('3','"+s+"')"
conn.execute exec
'end if


end sub

fun
%>
...
...
Atai-Lu 2007-11-27
  • 打赏
  • 举报
回复
说明ACCESS库名gu.mdb,表sh1,表里字段name,z1,z2,z3,z4,z5,z6
3个随机数后写库存储,正如上面的那样,正确.

但如再执行5次上面的过程,
只是第二次要求往库里z2里写;同时要求往name里写2
...3次.....z3.....................3
...4次.........z4......................4
.....
......6次要求往库里z6里写.........................6
----------------------------------------------------------------------
楼主啊,这个...
能不能说明白点?看着有点糊涂,不知道你要问的是什么问题...

28,390

社区成员

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

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