求翻译ASP代码~~~~
<!--#includefile="Conn.asp"--><%dimsRsSetsRs=Conn.Execute("selectcount(*)fromBath")if...
<!--#include file="Conn.asp" -->
<%
dim sRs
Set sRs=Conn.Execute("select count(*) from Bath")
if sRs(0)>=30 then
response.write"<script>alert('服务内容记录不能超过30条');window.location.href='Bath_manage.asp';</script>"
else
Dim Bath_Name,Cost,Remarks
If Request.Form <> "" Then
Bath_Name = Trim(Request.Form("Bath_Name"))
Cost = Trim(Request.Form("Cost"))
Remarks = Trim(Request.Form("Remarks"))
Set Rs = Conn.Execute("select * from Bath where Bath_Name = '"& Bath_Name &"'")
If Not Rs.Eof Then
response.write"<script>alert('此服务内容已经存在');history.back();</script>"
else
Conn.Execute("insert into Bath ( Bath_Name,Cost,Remarks ) values ('"& Bath_Name &"','"& Cost &"' , '"& Remarks &"')")
response.write"<script>alert('添加成功');window.location='Bath_add.asp';</script>"
end if
Set Rs = Nothing
End If
end if
Set sRs = Nothing
%> 展开
<%
dim sRs
Set sRs=Conn.Execute("select count(*) from Bath")
if sRs(0)>=30 then
response.write"<script>alert('服务内容记录不能超过30条');window.location.href='Bath_manage.asp';</script>"
else
Dim Bath_Name,Cost,Remarks
If Request.Form <> "" Then
Bath_Name = Trim(Request.Form("Bath_Name"))
Cost = Trim(Request.Form("Cost"))
Remarks = Trim(Request.Form("Remarks"))
Set Rs = Conn.Execute("select * from Bath where Bath_Name = '"& Bath_Name &"'")
If Not Rs.Eof Then
response.write"<script>alert('此服务内容已经存在');history.back();</script>"
else
Conn.Execute("insert into Bath ( Bath_Name,Cost,Remarks ) values ('"& Bath_Name &"','"& Cost &"' , '"& Remarks &"')")
response.write"<script>alert('添加成功');window.location='Bath_add.asp';</script>"
end if
Set Rs = Nothing
End If
end if
Set sRs = Nothing
%> 展开
2个回答
展开全部
<!--#include file="Conn.asp" --> 这行声明包含文件conn.asp,该文件应该是用来链接数据库的
<%
dim sRs '定义变量srs,用于下面的记录集
Set sRs=Conn.Execute("select count(*) from Bath") '将sql语句产生的记录集取到变量srs中
if sRs(0)>=30 then '判断记录集里面的第0字段的值是否大于等于30,此处即count(*)
response.write"<script>alert('服务内容记录不能超过30条');window.location.href='Bath_manage.asp';</script>" '如果是,则跳出提示框后网页跳转到Bath_manage.asp页面
else '否则执行下面的语句
Dim Bath_Name,Cost,Remarks '定义三个变量
If Request.Form <> "" Then '判断上个页面提交的内容是否为空,如果不为空则执行下面的语句
Bath_Name = Trim(Request.Form("Bath_Name")) '将上个页面的Bath_Name的值赋值给变量Bath_Name,下面两句功能同这句
Cost = Trim(Request.Form("Cost"))
Remarks = Trim(Request.Form("Remarks"))
Set Rs = Conn.Execute("select * from Bath where Bath_Name = '"& Bath_Name &"'") '将sql语句的记录集赋值给Rs
If Not Rs.Eof Then '判断rs记录集是否不为空记录集(eof为记录集结束标志),如果是则
response.write"<script>alert('此服务内容已经存在');history.back();</script>" '跳出提示框后返回上个页面
else '否则
Conn.Execute("insert into Bath ( Bath_Name,Cost,Remarks ) values ('"& Bath_Name &"','"& Cost &"' , '"& Remarks &"')") '将上个页面提交来的三个值插入到数据库Bath对应的字段中
response.write"<script>alert('添加成功');window.location='Bath_add.asp';</script>" '跳出提示框后页跳转到Bath_add.asp页面
end if '结束判断
Set Rs = Nothing '释放rs记录集
End If '结束判断
end if '结束判断
Set sRs = Nothing '释放srs记录集
%>
<%
dim sRs '定义变量srs,用于下面的记录集
Set sRs=Conn.Execute("select count(*) from Bath") '将sql语句产生的记录集取到变量srs中
if sRs(0)>=30 then '判断记录集里面的第0字段的值是否大于等于30,此处即count(*)
response.write"<script>alert('服务内容记录不能超过30条');window.location.href='Bath_manage.asp';</script>" '如果是,则跳出提示框后网页跳转到Bath_manage.asp页面
else '否则执行下面的语句
Dim Bath_Name,Cost,Remarks '定义三个变量
If Request.Form <> "" Then '判断上个页面提交的内容是否为空,如果不为空则执行下面的语句
Bath_Name = Trim(Request.Form("Bath_Name")) '将上个页面的Bath_Name的值赋值给变量Bath_Name,下面两句功能同这句
Cost = Trim(Request.Form("Cost"))
Remarks = Trim(Request.Form("Remarks"))
Set Rs = Conn.Execute("select * from Bath where Bath_Name = '"& Bath_Name &"'") '将sql语句的记录集赋值给Rs
If Not Rs.Eof Then '判断rs记录集是否不为空记录集(eof为记录集结束标志),如果是则
response.write"<script>alert('此服务内容已经存在');history.back();</script>" '跳出提示框后返回上个页面
else '否则
Conn.Execute("insert into Bath ( Bath_Name,Cost,Remarks ) values ('"& Bath_Name &"','"& Cost &"' , '"& Remarks &"')") '将上个页面提交来的三个值插入到数据库Bath对应的字段中
response.write"<script>alert('添加成功');window.location='Bath_add.asp';</script>" '跳出提示框后页跳转到Bath_add.asp页面
end if '结束判断
Set Rs = Nothing '释放rs记录集
End If '结束判断
end if '结束判断
Set sRs = Nothing '释放srs记录集
%>
追问
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询