数据库名:data.mdb
表名:employee
字段
ID 自动编号
EmployeeName 文本
DepartmentID 数字
Birthday 日期/时间
- - - - - - - - - - - -
asp代码:
<%
remindDays = 7 '提醒日期
set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data.mdb")
conn.Open connstr
sql = "select * from employee where datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())<=" & remindDays & " and datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())>=0 order by ID desc"
set rs = conn.execute(sql)
if not rs.eof then
response.write("近" & remindDays & "天过生日的员工:<br />")
do while not rs.eof
response.Write("-----------------------------------<br />")
response.Write("姓名:" & rs("EmployeeName") & "<br />")
response.Write("生日:" & rs("Birthday") & "<br />")
rs.movenext
loop
else
response.write("近" & remindDays & "天没有过生日的员工")
end if
rs.close
set rs =nothing
%>
----------------------------------------------------------------
<%
set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data.mdb")
conn.Open connstr
sql = "select * from employee where datediff('d', cstr(year(date())) + '-' + cstr(month(Birthday)) + '-' + cstr(day(Birthday)),date())=0 order by ID desc"
set rs = conn.execute(sql)
if not rs.eof then
response.write("今天过生日的员工:<br />")
do while not rs.eof
response.Write("姓名:<span style=""color:#f00"">" & rs("EmployeeName") & "</span>——"&rs("DepartmentID")&"<br />")
rs.movenext
loop
else
response.write("今天没有过生日的员工")
end if
rs.close
set rs =nothing
%>
3.不冲突,连接字符串写对了就行
ASP员工生日提醒
本文章被留下的脚印 (0)
各位正在潜水的同学请注意,有 0 位无聊人士 在异次元附近海域出没!
小X的哥哥的同学的老师的儿子的妈妈养的小猫的表弟的主人的朋友说看帖不回会被鄙视de