asp中自定义函数调用问题

2025-02-24 11:48:18
推荐回答(2个)
回答1:

function sanji(ID)
set rs=server.createobject("adodb.recordset")
sql = "SELECT count(*) as sanji FROM PoliceStation where AreaID="&Cint(ID)&" and PSGrade='三级'"
rs.open sql,conn,1,1
sanji = rs("sanji")
rs.close()
set rs = nothing
end function

<%Response.Write(sanji(18))%>


把18改成你想要的ID就行了

回答2:

Function S_Count(AID)
On Error Resume Next
Dim SQL,Rs,tempStr
SQL="Select count(*) as sanji From [PoliceStation] Where AreaID="&Cint(AID)&" and PSGrade='三级'"
Set Rs=Conn.Execute(SQL)
If Not(Rs.Eof And Rs.Bof) Then
tempStr=Rs("sanji")
End If
Rs.Close:Set Rs=Nothing
S_Count=tempStr
End Function