Reading 3 rows

eramgarden

Contributor
Joined
Mar 8, 2004
Messages
579
I have a sql that returns 3 rows and want to assign each row to a Label...

I tried using "Nextresult" but I get this error:
Invalid attempt to read when no data is present.

---
This is what I have:

Dim cnn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnString"))
Dim cmd As SqlCommand = cnn.CreateCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select label from lablem where original_label = 'Caller' ;" & _
"Select label from labelm where original_label = 'Company' ;" & _
"Select label from labelm where original_label = 'Incident' ; "


cnn.Open()

Dim dr As SqlDataReader = cmd.ExecuteReader()

If dr.Read() Then
btnContact.Text = dr.GetString(0)
dr.NextResult()
btnSite.Text = dr.GetString(0)
dr.NextResult()
btnIncident.Text = dr.GetString(0)

End If

dr.Close()
cnn.Close()

any ideas on how to do this?
 
Back
Top