SQL, propriété - Exemple (VBScript)
Important
À compter de Windows 8 et Windows Server 2012, les composants serveur RDS ne sont plus inclus dans le système d’exploitation Windows (voir Windows 8 et livre de recettes de compatibilité Windows Server 2012 pour plus de détails). Les composants clients RDS seront supprimés dans une prochaine version de Windows. Évitez d’utiliser cette fonctionnalité dans le nouveau travail de développement et prévoyez de modifier les applications qui utilisent actuellement cette fonctionnalité. Les applications qui utilisent RDS doivent migrer vers wcf Data Service .
Le code suivant montre comment définir le RDS. DataControl paramètre SQL au moment du design et liez-le à un contrôle prenant en charge les données à l’aide de la base de données appelée Pubs, fournie avec Microsoft SQL Server. Pour tester l’exemple, copiez le code suivant dans un document ASP normal nommé SQLDesignVBS.asp sur votre serveur web.
<!-- BeginSQLDesignVBS -->
<%@ Language=VBScript %>
<html>
<head>
<meta name="VI60_DefaultClientScript" content=VBScript>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>SQL Property Example (VBScript)</title>
<style>
<!--
body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;
COLOR:black;
}
.thead {
background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}
.thead2 {
background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}
.tbody {
text-align: center;
background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
}
-->
</style>
</head>
<body>
<h1>SQL Property Example (VBScript)</h1>
<!-- RDS.DataControl -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID=RDC HEIGHT=1 WIDTH=1>
<PARAM NAME="SQL" VALUE="Select FirstName, LastName from Employees">
<PARAM NAME="SERVER" VALUE="https://<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider='sqloledb';Initial Catalog='Northwind';Integrated Security='SSPI';">
</OBJECT>
<!-- Data Table -->
<TABLE DATASRC=#RDC BORDER=1>
<TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD>
<TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
</TR>
</TABLE>
</body>
</html>
<!-- EndSQLDesignVBS -->
L’exemple suivant montre comment définir les paramètres nécessaires de RDS. DataControl au moment de l’exécution. Pour tester cet exemple, coupez et collez le code suivant dans un document ASP normal et nommez-le SQLRuntimeVBS.asp. Le script ASP identifie votre serveur.
<!-- BeginSQLRuntimeVBS -->
<%@ Language=VBScript %>
<html>
<head>
<meta name="VI60_DefaultClientScript" content=VBScript>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0">
<title>SQL Property Example (VBScript)</title>
<style>
<!--
body {
font-family: 'Verdana','Arial','Helvetica',sans-serif;
BACKGROUND-COLOR:white;
COLOR:black;
}
.thead {
background-color: #008080;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}
.thead2 {
background-color: #800000;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
color: white;
}
.tbody {
text-align: center;
background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;
}
-->
</style>
</head>
<body>
<h1>SQL Property Example (VBScript)</h1>
<H2>RDS API Code Examples </H2>
<H3>Remote Data Service SQL Property Set at Run Time</H3>
<!-- RDS.DataControl with no parameters set at design time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC HEIGHT=1 WIDTH=1>
</OBJECT>
<TABLE DATASRC=#RDC>
<TR>
<TD> <SPAN DATAFLD="FirstName"></SPAN> </TD>
<TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
<TD> <SPAN DATAFLD="Title"></SPAN> </TD>
<TD> <SPAN DATAFLD="Type"></SPAN> </TD>
<TD> <SPAN DATAFLD="Email"></SPAN> </TD>
</TR>
</TABLE>
<HR>
<Input Size=70 Name="txtServer" Value= "https://<%=Request.ServerVariables("SERVER_NAME")%>">
<BR>
<Input Size=70 Name="txtConnect" Value="Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind';">
<BR>
<Input Size=70 Name="txtSQL" VALUE="Select * from Employees">
<HR>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<Script Language="VBScript">
<!--
' Set parameters of RDS.DataControl at Run Time.
Sub Run_OnClick
RDC.Server = txtServer.Value
RDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.Value
RDC.Refresh
End Sub
-->
</Script>
</body>
</html>
<!-- EndSQLRuntimeVBS -->
Voir aussi
DataControl, objet (RDS)
sql, propriété