在不刷新页面的情况下调用远程asp脚本(3)
Dim SessionName, conn
const connstr = "driver={SQL Server}; server=202.0.0.108;uid=sa;pwd=;database=house"
SessionName = "House"
If Not IsObject(Session(SessionName)) Then
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
Set Session(SessionName) = conn
End If
Set OpenOrGet_Database = Session(SessionName)
End Function
%>
建立文件sql_pub.asp
<%
´取出城市资料
Function SelectCity()
Dim Conn, Sql, Rs, ArrCity, TmpArr(1,0)
Set Conn = OpenOrGet_Database
Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "Select distinct name,id from City"
Rs.Open Sql,Conn,3
if Rs.Eof then
TmpArr(0,0) = "城市"
TmpArr(1,0) = 0
Rs.Close
SelectCity = TmpArr
else
ArrCity = RS.GetRows()
Rs.Close
SelectCity = ArrCity
end if
End Function
´根据传来的CityId取出相应的地区资料
Function SelectArea(CityId)
Dim Conn, Sql, Rs, ArrArea, TmpArr(1,0)
Set Conn = OpenOrGet_Database
Set Rs = Server.CreateObject("ADODB.Recordset")
Sql =" Select name,id from Area where CityId=" & CityId & " order by id "
Rs.Open Sql,Conn,3
if Rs.Eof then
TmpArr(0,0) = "地区"
TmpArr(1,0) = 0
Rs.Close
SelectArea = TmpArr
else
ArrArea = RS.GetRows()
Rs.Close
内容版权声明:除非注明,否则皆为本站原创文章。