Popolare una DropDownList leggendo i dati da SQLServer
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim objCon As OleDBConnection
objCon = New OleDBConnection("Provider=sqloledb; _
Data Source=NOME_DATABASE_SERVER;Initial catalog=NOME_DATABASE; _
User Id=USER_NAME;Password=PASSWORD;")
Dim ds as new DataSet
Dim objAdapter As OleDBDataAdapter = New OleDBDataAdapter("Select ID, TESTO from TABELLA order by TESTO desc", objCon)
objAdapter.Fill(ds)
catList.DataSource=ds.tables(0).DefaultView
catList.DataValueField="ID"
catList.DataTextField="TESTO"
catList.DataBind()
end sub
</script>
<html>
<body>
<form runat="server">
<asp:DropDownList id="myDropDownList" runat="server"/>
</form>
</body>
</html>