<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
Sub Page_Load
lbl1.Text = "Ricerca Clienti per Nazione "
End Sub
Sub Submit(sender As Object, e As EventArgs)
Dim dbconn as OleDbConnection
Dim dbcomm as OleDbCommand
Dim dbread as OleDbDataReader
Dim strSQL As String
Dim nome As String
nome = NomeNazione.Text
dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("Northwind.mdb"))
dbconn.Open()
strSQL = "Select NomeSocietà, Città From Clienti "
strSQL &= "Where Paese = @param1 Order by NomeSocietà "
dbcomm = New OleDbCommand(strSQL, dbconn)
dbcomm.Parameters.Add(New OleDbParameter("@param1", NomeNazione.Text))
dbread = dbcomm.ExecuteReader()
clienti.DataSource = dbread
clienti.DataBind()
dbread.Close()
dbconn.Close()
End Sub
</script>
<html>
<body>
<form id="Form1" runat="server">
<p><asp:label id="lbl1" runat="server" font-bold="True" /></p>
<p>
Quale Nazione: <asp:TextBox id="NomeNazione" runat="server" />
</p>
<asp:Button ID="Button1" OnClick="Submit" Text="Cerca" runat="server" />
<p>
<asp:DataGrid id="clienti" runat="server">
</asp:DataGrid>
<p>
</form>
</body>
</html> |