<%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.ADO"%> <script language="VB" runat="server"> Sub Page_Load (SourceObj as Object, EveArg as EventArgs)
If Not Page.IsPostBack Then Dim mudCommand As ADODataSetCommand Dim mudConnection As ADOConnection Dim dSet As New DataSet Dim strSQL as String Dim connStr as String
strSQL = "SELECT CategoryID, CategoryName From Categories" connStr = "Provider = SQLOLEDB; Data Source=test; Initial Catalog=Northwind; User ID=sa; password=;"
mudConnection = New ADOConnection(connStr) mudCommand = New ADODataSetCommand(strSQL, mudConnection) mudCommand.FillDataSet(dSet, "Categories") mudCategories.DataSource = dSet.Tables("Categories").DefaultView mudCategories.DataBind() End If End Sub
Sub displayProducts (Source as Object, EveArg as EventArgs)
Dim mudCommand As ADODataSetCommand Dim mudConnection As ADOConnection Dim dSet As New DataSet Dim strSQL as String Dim connStr as String
connStr = "Provider = SQLOLEDB; Data Source=test; Initial Catalog=Northwind; User ID=sa; password=;"
strSQL = "Select ProductID, ProductName From Products" strSQL = strSQL & " WHERE CategoryID = " & mudCategories.SelectedItem.Value
mudConnection = New ADOConnection(connStr) mudCommand = New ADODataSetCommand(strSQL, mudConnection) mudCommand.FillDataSet(dSet, "Products") mudProducts.DataSource = dSet.Tables("Products").DefaultView mudProducts.DataBind() End Sub