Figures

Figure 1 Debug Session for ASP.NET

Figure 1 Debug Session for ASP.NET

Figure 2 CustomerList.aspx.vb


Const ConnectionString = "server=localhost;uid=sa; " _ 
  & "pwd=;database=NorthWind"

Public Function RunSQLWithDataSet(ByVal sSQL As String) As DataSet

    Dim oDataSet As New DataSet()
    Dim oDataAdapter As SqlClient.SqlDataAdapter

    Try

        'Create New DataAdapter 
        oDataAdapter = New SqlClient.SqlDataAdapter(sSQL, _
        ConnectionString)

        'Fill Data Set from dataadapter
        oDataAdapter.Fill(oDataSet, "Table1")

        'Set return value of function
        Return oDataSet
    Catch e As Exception
      Throw New Exception( _
        "An exception occured in RunSQLWithDataSet", e)
    Finally
    End Try
    End Function

    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 ds As DataSet
    Dim sSQL As String

    sSQL = "Select * from customers"
    ds = RunSQLWithDataSet(sSQL)

    DataGrid1.DataSource = ds
    DataGrid1.DataBind()
    End Sub
Show: