Maim.html文件代码如下
<HTML>
<HEAD>
<TITLE>RS技术的实现例子</TITLE>
</HEAD>
<BODY>
<script language=\"JavaScript\" src=\"http://YourServer/_ScriptLibrary/rs.htm\"></script>
<script language=\"JavaScript\">
RSEnableRemoteScripting(\"http://YourServer/_ScriptLibrary\");
</script>
<h1>雇员信息</h1>
<hr>
<form name=MyForm>
请输入你想查询的名字:
<br><input type=text name=\"empLastName\" size=40>
<input type=button name=btnExecute style=\"width=150\"
value=\"获取信息\"
onclick=\"execAsynch(empLastName.value)\">
</form>
<hr>
<SCRIPT LANGUAGE=\"javascript\">
var serverURL = \"http://YourServer\";
var pageURL = \"/batman/EmpData.asp\";
function refreshPage(co)
{
if (co.status != 0) {
alert(\"发生异常错误\\n\" +
message);
}
strText = co.return_value;
top.info.location = \"info.asp?info=\" + escape(strText);
}
function execAsynch(empLastName)
{
RSExecute(serverURL+pageURL, \"GetEmpInfoAsArray\",
empLastName, refreshPage);
}
</SCRIPT>
</BODY>
</HTML>
info.asp文件代码
<HTML>
<BODY>
<%
Response.Write Request.ServerVariables(\"REMOTE_USER\")
strText = Request.QueryString(\"info\")
If strText = \"\" Then Response.End
arrData = split(strText, \"|\")
arrLabels = split(\"职工,头衔,城市,雇佣日期\", \",\")
%>
<table border=0>
<%
for i=0 to 3
Response.Write \"<tr>\"
Response.Write \"<td><b>\" & arrLabels(i) & \"</b></td>\"
Response.Write \"<td><i>\" & arrData(i) & \"</i></td>\"
next
%>
</table>
</BODY>
</HTML>
EmpData.asp文件
<%@ LANGUAGE=VBSCRIPT %>
<% RSDispatch %>
<SCRIPT RUNAT=SERVER Language=javascript>
<!--#INCLUDE VIRTUAL=\"/_ScriptLibrary/RS.ASP\"-->
function Description()
{
this.GetEmpInfoAsArray = DoGetData;
}
public_description = new Description();
function DoGetData(empName)
{
sql = \"select * from 雇员 where [名字]=\"\" + empName + \"\"\";
rst = new ActiveXObject(\"ADODB.Recordset\");
rst.CursorLocation = 3;
rst.Open(sql, \"NW\");
i = 0;
strText = \"\";
if (rst.RecordCount == 1) {
strText += rst.Fields(\"雇员ID\").Value + \" - \" +
rst.Fields(\"尊称\").Value + \" \" +
rst.Fields(\"姓氏\").Value + \" \" +
rst.Fields(\"名字\").Value;
strText += \"|\";
strText += rst.Fields(\"头衔\").Value;
strText += \"|\";
strText += rst.Fields(\"城市\").Value + \" \" +
rst.Fields(\"地区\").Value + \", \" +
rst.Fields(\"国家\").Value;
strText += \"|\";
d = new Date(rst.Fields(\"雇用日期\").Value);
strText += (1+d.getMonth()) + \"/\" + d.getDate() + \"/\" +d.getYear();
}
return strText;
}
</SCRIPT>

