在不重新整理頁面的情況下呼叫遠端asp指令碼 (轉)
在不重新整理頁面的情況下呼叫遠端asp指令碼 (轉)[@more@]
if exists ( * from syss where id = object_id(N'[o].[City]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[City]
GO
if exists (select * from sysobjects where id = object_id(N'[dbo].[Area]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Area]
GO
CREATE TABLE [dbo].[City] (
[id] [int] NTITY (1, 1) NOT NULL ,
[name] [nvarchar] (10) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Area] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[CityId] [int] NULL ,
[name] [nvarchar] (20) NULL
) ON [PRIMARY]
GO
INSERT INTO City (id,name) Values(1,"廣州")
INSERT INTO City (id,name) Values(2,"上海")
INSERT INTO City (id,name) Values(3,"北京")
INSERT INTO Area (id,CityId,name) Values(1,1,"天河")
INSERT INTO Area (id,CityId,name) Values(2,1,"白雲")
INSERT INTO Area (id,CityId,name) Values(3,2,"虹口")
INSERT INTO Area (id,CityId,name) Values(4,2,"寶山")
INSERT INTO Area (id,CityId,name) Values(5,2,"靜安")
INSERT INTO Area (id,CityId,name) Values(6,3,"海淀")
INSERT INTO Area (id,CityId,name) Values(7,3,"朝陽")
2.建立
建立檔案CityData.
建立檔案jsconn.asp
建立檔案pub.asp
Function OpenOrGet_Database
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
SelectArea = ArrArea
end if
End Function
%>
建立檔案test.asp
<!--#include VIRTUAL="pub.asp"-->
<!--#include VIRTUAL="Sql_pub.asp"-->
Dim arrCity, arrArea, strPathInfo, strServerName, strServerPort, i, TmpStr
strPathInfo = Request.ServerVariables("PATH_INFO")
strServerName = Request.ServerVariables("SERVER_NAME")
strServerPort = Request.ServerVariables("SERVER_PORT")
if len(strServerPort) = 0 then
strServerPort = ""
else
strServerPort = ":" + strServerPort
end if
strPathInfo = "http://" & strServerName & strServerPort & ""
arrCity = SelectCity()
arrArea = SelectArea(arrCity(1,0))
%>
Untitled Document
1.請在 SERVER 中建一 name:house 在house中執行下列指令碼
if exists ( * from syss where id = object_id(N'[o].[City]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[City]
GO
if exists (select * from sysobjects where id = object_id(N'[dbo].[Area]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Area]
GO
CREATE TABLE [dbo].[City] (
[id] [int] NTITY (1, 1) NOT NULL ,
[name] [nvarchar] (10) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[Area] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[CityId] [int] NULL ,
[name] [nvarchar] (20) NULL
) ON [PRIMARY]
GO
INSERT INTO City (id,name) Values(1,"廣州")
INSERT INTO City (id,name) Values(2,"上海")
INSERT INTO City (id,name) Values(3,"北京")
INSERT INTO Area (id,CityId,name) Values(1,1,"天河")
INSERT INTO Area (id,CityId,name) Values(2,1,"白雲")
INSERT INTO Area (id,CityId,name) Values(3,2,"虹口")
INSERT INTO Area (id,CityId,name) Values(4,2,"寶山")
INSERT INTO Area (id,CityId,name) Values(5,2,"靜安")
INSERT INTO Area (id,CityId,name) Values(6,3,"海淀")
INSERT INTO Area (id,CityId,name) Values(7,3,"朝陽")
2.建立
建立檔案CityData.
建立檔案jsconn.asp
建立檔案pub.asp
Function OpenOrGet_Database
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
SelectArea = ArrArea
end if
End Function
%>
建立檔案test.asp
<!--#include VIRTUAL="pub.asp"-->
<!--#include VIRTUAL="Sql_pub.asp"-->
Dim arrCity, arrArea, strPathInfo, strServerName, strServerPort, i, TmpStr
strPathInfo = Request.ServerVariables("PATH_INFO")
strServerName = Request.ServerVariables("SERVER_NAME")
strServerPort = Request.ServerVariables("SERVER_PORT")
if len(strServerPort) = 0 then
strServerPort = ""
else
strServerPort = ":" + strServerPort
end if
strPathInfo = "http://" & strServerName & strServerPort & ""
arrCity = SelectCity()
arrArea = SelectArea(arrCity(1,0))
%>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-995820/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 《前端實戰總結》如何在不重新整理頁面的情況下改變URL前端
- JS指令碼中重新整理當前頁面的方法JS指令碼
- 用指令碼解決ASP.NET頁面重新整理問題 (轉)指令碼ASP.NET
- 可連線遠端主機情況下新增私鑰到遠端主機
- ASP.NET重新整理頁面的六種方法ASP.NET
- 在指令碼中呼叫cassandra客戶端命令指令碼客戶端
- 可以重新整理頁面的javascript程式碼JavaScript
- ASP.NET頁面重新整理:自動重新整理頁面的實現方法總結ASP.NET
- ASP.NET重新整理頁面的六種方法總結ASP.NET
- 在不影響程式使用的情況下新增shellcode
- 在不安裝oracle客戶端的情況下,使用PLSQLOracle客戶端SQL
- MySQL遠端訪問時,非常慢,甚至出現連不上的情況MySql
- 在不重灌Windows情況Ç(轉)Windows
- 檢查備份情況的指令碼指令碼
- 遠端分發sh指令碼指令碼
- Sqlserver查詢alwayson同步情況指令碼(2)SQLServer指令碼
- Sqlserver查詢alwayson同步情況指令碼(1)SQLServer指令碼
- iframe下重新整理頁面無法重新整理當前頁面的解決辦法
- 在ASP檔案中呼叫DLL (轉)
- Linux下遠端桌面的配置(VNC)薦LinuxVNC
- 9、在Shell指令碼中呼叫其他指令碼指令碼
- 3.1.5.3 在不掛載資料庫的情況下啟動例項資料庫
- 不應該在沒有 sudo 的情況下執行 Docker 的原因Docker
- 在Watir中呼叫JavaScript指令碼JavaScript指令碼
- Java遠端呼叫Java
- 呼叫layoutSubviews各種情況分析View
- 檢視過去的session鎖情況指令碼Session指令碼
- shell指令碼不換行重新整理資料指令碼
- PbootCMS內頁打不開的常見情況彙總boot
- 在不會使用excel函式的情況下如何完成複雜任務Excel函式
- 在什麼情況下用index unique scansIndex
- SSH 無密碼遠端執行指令碼密碼指令碼
- 驗證碼不顯示是什麼情況
- 在loadrunner中呼叫QTP指令碼QT指令碼
- 在不需要知道密碼的情況下 Hacking MSSQL密碼SQL
- 遠端桌面的處理
- ASP.NET頁面重新整理和定時跳轉ASP.NET
- Centos下使用php呼叫shell指令碼CentOSPHP指令碼