ASP员工生日提醒
发布网友
发布时间:17小时前
我来回答
共2个回答
热心网友
时间:17小时前
数据库名: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.不冲突,连接字符串写对了就行
热心网友
时间:17小时前
寒云你好:
因问题补充要限制字数,所以我换了个名字将修改后的代码发过来:
<font size="4" face="黑体" color="#ff0000">
<%
remindDays = 0 '提醒日期
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("今天过生日的员工:"& "<br />")
do while not rs.eof
response.Write("姓名:" & rs("EmployeeName") )
response.Write("--" & rs("DepartmentID") & " ")
rs.movenext
loop
else
response.write("近" & remindDays & "天没有过生日的员工")
end if
rs.close
set rs =nothing
%> </font>