S
SmartbizAustralia
Hi,
This seems to be a neglected bit of info as everyone gets carried away
with data binding examples instead.
Can simply use the datareader as below:
Private Sub PopulateControls1()
Dim sSql As String
Dim cn As SqlConnection
cn = New SqlConnection(m_sConnection)
cn.Open()
sSql = "Select top 10 * from Person.Contact"
Dim sqlCmd As New SqlCommand(sSql, cn)
Dim r As SqlDataReader = sqlCmd.ExecuteReader()
'Get the first line
r.Read()
Me.Label1.Text = "First Name"
Me.TextBox1.Text = r.Item("FirstName")
'Now get the new line
r.Read()
Me.Label2.Text = "First Name"
Me.TextBox2.Text = r.Item("FirstName")
cn.Close()
End Sub
but would love to do the same with a dataset instead.
But how do you walk through each row and select particular columns in a
dataset?
This seems to be a neglected bit of info as everyone gets carried away
with data binding examples instead.
Can simply use the datareader as below:
Private Sub PopulateControls1()
Dim sSql As String
Dim cn As SqlConnection
cn = New SqlConnection(m_sConnection)
cn.Open()
sSql = "Select top 10 * from Person.Contact"
Dim sqlCmd As New SqlCommand(sSql, cn)
Dim r As SqlDataReader = sqlCmd.ExecuteReader()
'Get the first line
r.Read()
Me.Label1.Text = "First Name"
Me.TextBox1.Text = r.Item("FirstName")
'Now get the new line
r.Read()
Me.Label2.Text = "First Name"
Me.TextBox2.Text = r.Item("FirstName")
cn.Close()
End Sub
but would love to do the same with a dataset instead.
But how do you walk through each row and select particular columns in a
dataset?