Imports System.Data.SqlClient

 

Public Class PagerExample1

      Inherits System.Web.UI.Page

      Protected WithEvents dlCustomers As System.Web.UI.WebControls.DataList

 

#Region " Web Form Designer Generated Code "

 

      'This call is required by the Web Form Designer.

      <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

 

      End Sub

 

      Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

            'CODEGEN: This method call is required by the Web Form Designer

            'Do not modify it using the code editor.

            InitializeComponent()

      End Sub

 

#End Region

 

      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            'Put user code to initialize the page here

            Dim connectionString As String = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;Persist Security Info=False;"

            Dim connection As SqlConnection = New SqlConnection(connectionString)

            Dim command As SqlCommand = New SqlCommand("SELECT * FROM Customers", connection)

            Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)

            Try

                  connection.Open()

                  Dim ds As DataSet = New DataSet()

                  adapter.Fill(ds)

                  dlCustomers.DataSource = ds.Tables(0)

                  dlCustomers.DataBind()

            Finally

                  connection.Close()

            End Try

 

      End Sub

 

End Class