<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%@ Page language="VB" Debug="false" %>
<HTML>
<script language="vbscript" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & Server.MapPath("database/utenti.mdb"))
Dim myCmd As OleDbCommand = New OleDbCommand("select nome, cognome, email from utenti", myConn)
If Not Page.IsPostBack Then
Try
DropDownList1.Items.Clear
myConn.Open()
Dim aReader As OleDbDataReader = myCmd.ExecuteReader()
Try
Do While aReader.Read()
Dim nomeCompleto As String = aReader("nome") + " " + aReader("cognome")
Dim email As String = aReader("email").ToString()
Dim li As ListItem = New ListItem(nomeCompleto, email)
DropDownList1.Items.Add(li)
Loop
Finally
aReader.Close()
End Try
Finally
myConn.Close()
End Try
End If
End Sub
</script>
<body>
<form name="Form1" runat="server" ID="Form1">
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
</form>
</body>
</HTML>