新微赢技术网

标题: 如何累加????? [打印本页]

作者: 释放压力    时间: 2010-1-10 06:06
标题: 如何累加?????
有10个同学,其中有三个同学是同一天生日,现在要写一段语句通过select 语句和循环语句将三名同学的姓名读出来且赋值给name,即name= a(0)+a(1)+a(2),再以response.write name 输出,不知用数组如何写??拜托各位了
作者: 尐妖    时间: 2010-1-10 06:06
楼主的代码怎么写的?
作者: v九天〓云龙    时间: 2010-1-10 06:07
sql="select * from member where DateDiff('d',birthday,'"&Year(now())&"-"&Month(now())&"-"&Day(Now())&")=0 And DateDiff('m',birthday,'"&Year(now()&"-"&Month(now())&"-"&Day(now)&")=0 "
多了一个*号
作者: 封xin封mg    时间: 2010-1-10 06:07
语句如下:(数据库连接文件已经在上面了)
<%
set rs=server.createobject("adodb.recordset")
sql="select * from member where DateDiff('d',birthday,'"&Year(now())&"-"&Month(now())&"-"&Day(Now())&")=0 And DateDiff('m',birthday,'"&Year(now*()&"-"&Month(now())&"-"&Day(now)&")=0 "
rs.Open sql,conn,1,1
Do while not rs.EOF
   Response.Write "今天生日的用户"&rs("membername")
   rs.MoveNext
Loop
%>

错误提示:
错误类型:
Microsoft VBScript 编译器错误 (0x800A03EA)
语法错误
/0315/admin/case_tj/dealcount.asp, line 960, column 145
sql="select * from member where DateDiff('d',birthday,'"&Year(now())&"-"&Month(now())&"-"&Day(Now())&")=0 And DateDiff('m',birthday,'"&Year(now*()&"-"&Month(now())&"-"&Day(now)&")=0 "



上面错误提示说明以下这句话是错的.
sql="select * from member where DateDiff('d',birthday,'"&Year(now())&"-"&Month(now())&"-"&Day(Now())&")=0 And DateDiff('m',birthday,'"&Year(now*()&"-"&Month(now())&"-"&Day(now)&")=0 "
作者: 龙行天下    时间: 2010-1-10 06:07
谢谢,谢谢,我在一次感到了大家积极帮助的火热的心,只用一句话总结,世上还是好人多呀,再次表示感谢,等我测试完一定再回复。
作者: 小点点14504    时间: 2010-1-10 06:07
Set rs=con.Execute("select name from [user] where DateDiff('d',birthday,'"&Year(now())&"-"&Month(now())&"-"&Day(Now())&")=0 And DateDiff('m',birthday,'"&Year(now*()&"-"&Month(now())&"-"&Day(now)&")=0 ")

Do while not rs.EOF
   Response.Write "今天生日的用户"&rs("name")
   rs.MoveNext
Loop
作者: 星溯~~~~天空    时间: 2010-1-10 06:07
?为什么要累加?
用select循环直接用rs输出呢?
比如
Access数据库
Set rs=con.Execute("select name from [user] where DateDiff('d',birthday,'"&Year()&"-"&Month()&"-"&Day(Now)&")=0")
Do Until rs.EOF
   Response.Write "今天生日的用户"&rs("name")
   rs.MoveNext
Loop
作者: 一世豪杰    时间: 2010-1-10 06:07
再次表示感谢,我才学习不久,所以很多都不熟悉,希望以后多多指教。
但是按照这条语句进行查询,总是出现错误,说连接数据库时间超长,不知何故,望能解答。
作者: 别问我是谁    时间: 2010-1-10 06:07
Set rs=con.Execute("select name from [user] where DateDiff('d',birthday,'"&Year()&"-"&Month()&"-"&Day(Now)&")=0 And DateDiff('m',birthday,'"&Year()&"-"&Month()&"-"&Day(Now)&")=0 ")
加And连接即可
作者: ^o^星禾じ☆v    时间: 2010-1-10 06:07
感谢帮忙,我还有点没弄明白
DateDiff('d',birthday,'"&Year()&"-"&Month()&"-"&Day(Now)&"')=0"
这句好像有点问题,生日相同的只有月和日,所以必须取出birthday中的月、日与今天系统的月、日相减为0才对吧,不知说的是否对,再次谢谢回帖




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2