codice:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim result As String = ""
Try
result = "Ci sono " & RisultatoAggregazioneSQL(StringaConnessioneTest, "select count(*) from campi").ToString & " record"
Catch ex As Exception
result = ex.Message()
End Try
Me.Label1.Text = result
End Sub
Public Function RisultatoAggregazioneSQL(ByVal StringaConnessione$, ByVal stringaSQL$) As Object
Dim Connessione As OleDbConnection = Nothing
Dim Comando As OleDbCommand
Try
Connessione = New OleDbConnection(StringaConnessione)
Connessione.Open()
Comando = New OleDbCommand(stringaSQL, Connessione)
RisultatoAggregazioneSQL = Comando.ExecuteScalar()
Catch er As Exception
Throw
Finally
If Connessione IsNot Nothing Then Connessione.Close()
End Try
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server" >
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</form>
</body>
</html>