VB .NET | READ THE RESULTSET

Listing 7. This method, CustomerLists OnLoad event, submits a call object to a data service and reads the result rows, which are returned as a collection of row objects.

Protected Overrides Sub OnLoad(ByVal e As _
		System.EventArgs)
		MyBase.OnLoad(e)

		Dim Resultset As List(Of CustomersFetchOverviewRow)
		Dim NewRow As DataGridViewRow

		'
		' Connect to the Northwind database
		'
		Dim DB As New SqlServerDataService
		DB.ConnectionName = "Default"

		'
		' Call a procedure yielding a resultset
		'
		Resultset = DB.Query(Of _
			CustomersFetchOverviewRow)(New _
			CustomersOverviewFetch)
		For Each Customer As CustomersFetchOverviewRow In _
			Resultset
		NewRow = m_Grid.Rows(m_Grid.Rows.Add)
		NewRow.Cells(m_colID.Index).Value = Customer.ID
		NewRow.Cells(m_colCity.Index).Value = Customer.City
		NewRow.Cells(m_colCountry.Index).Value = _
			Customer.Country
		NewRow.Cells(m_colName.Index).Value = _
			Customer.CompanyName
		NewRow.Cells(m_colRegion.Index).Value = _
			Customer.Region
		Next

	End Sub
comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.