Hi,
Well, I just finish to try a test about remote script that I have
downloaded from microsof site.
Every thing is working and the idea of remote scripting is very interesting.
I copy here two examples:
One to read a SQL table and display and the other to insert data in a SQL
table.
Be careful to put in the right directory the file that you should download
from Microsoft site:
RS.ASP
RS.HTM
http://msdn.microsoft.com/scripting/default.htm?/scripting/remotescripting/d
ocs/default.htm
----------------------------- DataClient.ASP
----------------------------------------------
<%@ Language=VBScript %>
<%'-------- INCLUDE FILES ------------------------------------------%>
<!--#INCLUDE FILE="../../Routine/Control.asp"-->
<!--#include file="../../Include/ConnectionString.inc" -->
<!-- #Include file="../../Include/ADOVBS.INC" -->
<!--#include file="../../Include/userlogin.asp"-->
<%'-------- END include files ------------------------------------------%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript" src="RS.HTM"></script>
<SCRIPT LANGUAGE="JavaScript">
RSEnableRemoteScripting("http://dev.dctint.dctnet.coe.int/management/Clock_I
n/Test/")
</SCRIPT>
<%'************************************
'** CONNECTION ADODB **
'************************************
Set MyConn = Server.CreateObject("ADODB.Connection")
Call MyConn.Open(CONNECTION_STRING_DSN, CONNECTION_STRING_UID,
CONNECTION_STRING_PWD)
'************************************%>
<FORM name=FormAgent>
<SELECT name=MATRICULE onchange=LeAgent()>
<%
'set Rs = MyConn.Execute("SELECT MATRICULE, NOMAG, PRENOMAG FROM AGENTS
ORDER BY NOMAG")
qd = "SELECT matricule, nomag, prenomag, domain_key "
qd = qd & "FROM Agents WHERE domain_key LIKE '" & LoggedOnUser & "' "
Set Rs=MyConn.Execute(qd)
Response.Write "Liste des Agents / Agents list"
Response.Write "<OPTION>Choisir dans la liste</OPTION>" 'If no selected
agent no second page.
while not Rs.eof
Response.Write "<OPTION value=" & Rs.fields("MATRICULE").value & ">" &
Rs.fields("NOMAG").value & " " & Rs.fields("PRENOMAG").value & "</OPTION>"
Rs.movenext
Wend
Response.Write "QUI "
Rs.close
set Rs = nothing
Set MyConn=Nothing%>
</SELECT>
<P> </P>
<input type="text" size=40 NAME="txt3"><BR>
<br>
<input type="text" NAME="txt1"><BR>
<input type="text" size=50 NAME="txt2"><BR>
<input type="text" size=40 NAME="txt4"><BR>
<!--<input type="button" Value="Confirm" name="InserClock"><BR>-->
<input type="button" onclick=LeClick() Value="Confirm"
name="InserClock"><BR>
</form>
</BODY>
</HTML>
<%'</Script>
'<SCRIPT LANGUAGE="JavaScript" for="InserClock" event="onclick">
'<SCRIPT LANGUAGE="JavaScript" for="MATRICULE" event="onchange">
%>
<%'=================== SCRIPT ===========================================%>
<SCRIPT LANGUAGE="JavaScript">
function LeAgent()
{
//Alert("QUI Matricule ")
matricule=FormAgent.elements["MATRICULE"].value;
Dat="01/01/01"
co = RSExecute("RemoteDataServer.asp","DataAg",matricule,Dat);
FormAgent.elements["txt3"].value=co.return_value;
}
function LeClick()
{
//Alert("QUI")
matricule=FormAgent.elements["txt1"].value;
MornArrHo=FormAgent.elements["txt2"].value;
co = RSExecute("RemoteDataServer.asp","InsClock",matricule,MornArrHo);
FormAgent.elements["txt4"].value=co.return_value;
}
function LeAgentAS()
{
matricule=FormAgent.elements["MATRICULE"].value;
Dat="01/01/01"
context = "Contx Asynchronous";
co
RSExecute("RemoteDataServer.asp","DataAg",matricule,Dat,showResults,context)
;
if (co.status == -1)
{FormAgent.elements["txt2"].value = "Call failed";}
else
{FormAgent.elements["txt2"].value = "Call succeeded, return value = " +
co.return_value;}
}
function showResults(co)
{
typeOp = co.context;
rValue = co.return_value;
FormAgent.elements["txt3"].value = typeOp +" "+ rValue;
}
</script>
--------------- END -- DataClient.asp
----------------------------------------------------------
--------------------- DataServer.ASP
-------------------------------------------------------------
<%@ Language=VBScript %>
<%RSDispatch%>
<!--#INCLUDE FILE="RS.ASP"-->
<!--#include file="../../Include/ConnectionString.inc" -->
<!--#Include file="../../Include/ADOVBS.INC" -->
<SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
var public_description = new MyServerMethods();
function MyServerMethods()
{
this.DataAg = Function( 'n1','n2','return SearchAg(n1,n2)' );
this.InsClock = Function( 'n1','n2','return InserClock(n1,n2)' );
}
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE="VBScript">
Function SearchAg(mat,Dat)
Set MyConn = Server.CreateObject("ADODB.Connection")
Call MyConn.Open(CONNECTION_STRING_DSN, CONNECTION_STRING_UID,
CONNECTION_STRING_PWD)
qd = "SELECT * FROM TotalTimeRec WHERE MATRICULE ='" & Mat & "' AND
MONTH_YEAR='" & Dat &"'"
Set Rs=MyConn.Execute(qd)
If Rs.EOF=False Then ''' SEARCH in TotalTimeRec ------------
Do Until Rs.EOF
VARTotMonthHours=Rs("TOTAL_MONTH_HOUR")
VARTotLeave=Rs("TOTAL_CONGES")
VARTotSick=Rs("TOTAL_ABSENCE")
VARTotMission=Rs("TOTAL_MISSION")
VARTotPartTime=Rs("TOTAL_PARTIEL")
VARAssimAbsence=Rs("TOTAL_ASSIMH")
VARTotRealizedTime=Rs("TOTAL_HOURS")
VARTotRekonableTime=Rs("TOTAL_RECKON")
VARLeave=Rs("LeaveDay")
VARSick=Rs("SickDay")
VARMission=Rs("MissionDay")
VARPartTime=Rs("PartTimeDay")
CredDebHour=Rs("TIME_CREDIT")
Rs.MoveNext
Loop
Else
SearchAg=""
Exit Function
End If
SearchAg=VARTotPartTime
Rs.close
set Rs = nothing
End Function
Function InserClock(mat,MornArrHo)
Set MyConn = Server.CreateObject("ADODB.Connection")
Call MyConn.Open(CONNECTION_STRING_DSN, CONNECTION_STRING_UID,
CONNECTION_STRING_PWD)
qd = "INSERT INTO IndivTimeRec (MATRICULE,MornArrHo)"
qd = qd + "VALUES ('"& mat & "'," & MornArrHo & ")"
Set Rs=MyConn.Execute(qd)
InserClock=" Record Inserted "
End Function
</SCRIPT>
-------------------- END -- DataServer.asp
----------------------------------------------------
Franco
___________________________________
Perretta Franco
software developer
Council of Europe
Department of Information Technology
Information Access Unit
67075 Strasbourg Cedex
tel: +33 (0)3 88 41 22 18 fax: +33 (0)3 88 41 39 67
mailto:franco.perretta@c...
http://www.coe.int
-----Original Message-----
From: xvoyager@h... [mailto:xvoyager@h...]
Sent: Thursday 29 March 2001 21:19
To: Interdev_Programming
Subject: Remote Scripting
Hi,
In my HTML form, I want to use remote scripting to populate other
textboxes on the same page. For example, if I typed in my employee ID and
click enter, I want to automatically populate the rest of my information
on the current page such as my name, address, city ...etc.
I went the microsoft scripting technology web page and tried using their
example and it doesn't work. If you encountered or have a solution or a
suggestion to this problem, I would be appreciated if you could share with
me.
Thanks
---
http://www.asptoday.com - the leading site for timely,
in-depth information for ASP developers everywhere.
franco.perretta@c...
$subst('Email.Unsub')