1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<%@ import Namespace= "System.Data" %>
<%@ import Namespace= "System.Data.SqlClient" %>
<script language= "VB" runat= "server" >
Sub Page_Load ()
Dim strConnection as String = "user id=MonCompte;password=toto;"
strConnection += "database=SourceDeDonnée;server=MonServer;"
strConnection += "Connect Timeout=30"
data_src.text = strConnection
Dim objConnection as New SqlConnection ( strConnection )
try
objConnection.Open ()
con_open.text= "Connection ouverte avec succès.<br /><br/>"
' Mettre le code de la requette et son affichage'
objConnection.Close ()
con_close.text= "Connection fermée.<br />"
catch e as Exception
con_open.text= "Erreur lors de l'ouverture.<br />"
con_close.text=e.ToString ()
end try
end Sub
</script>
< html >
<head></head>
<body>
<h4>Test de la connection </h4>
<asp:label id= "data_src" runat= "server" /></h4>
<asp:label id= "con_open" runat= "server" /><br />
<asp:label id= "con_close" runat= "server" /><br />
</body>
</html> |