G
Guest
Hello Every one!
In my web form I am accessing a stored procedure. I assign resulting data from stored procedure to datareader and with datareader I try to fill up DropDown List. But when I try to run code I am getting en error "Invalid attempt to read when no data is present." My stored procedure dont return null result.
Following is the code. Plz guide me how to solve this problem!
Sub fillControl()
Dim conSelect As SqlConnection
Dim cmdSelect As SqlCommand
Dim drSelect As SqlDataReader
conSelect = New SqlConnection(ConfigurationSettings.AppSettings("strcon"))
cmdselect = New SqlCommand("GetData", conSelect)
cmdselect.CommandType = CommandType.StoredProcedure
Try
conSelect.Open()
drSelect = cmdSelect.ExecuteReader()
ddlMediproID.DataSource = drSelect
ddlMediproID.DataTextField = drSelect.Item("MediproID") '***
ddlMediproID.DataValueField = drSelect.Item("ClientID")
ddlMediproID.DataBind()
drSelect.Close()
conSelect.Close()
Catch ex As Exception
lblErr.Text = ex.Message
Exit Sub
End Try
end sub
I am getting error at line with '***
Thanking you in advance.
Shail
In my web form I am accessing a stored procedure. I assign resulting data from stored procedure to datareader and with datareader I try to fill up DropDown List. But when I try to run code I am getting en error "Invalid attempt to read when no data is present." My stored procedure dont return null result.
Following is the code. Plz guide me how to solve this problem!
Sub fillControl()
Dim conSelect As SqlConnection
Dim cmdSelect As SqlCommand
Dim drSelect As SqlDataReader
conSelect = New SqlConnection(ConfigurationSettings.AppSettings("strcon"))
cmdselect = New SqlCommand("GetData", conSelect)
cmdselect.CommandType = CommandType.StoredProcedure
Try
conSelect.Open()
drSelect = cmdSelect.ExecuteReader()
ddlMediproID.DataSource = drSelect
ddlMediproID.DataTextField = drSelect.Item("MediproID") '***
ddlMediproID.DataValueField = drSelect.Item("ClientID")
ddlMediproID.DataBind()
drSelect.Close()
conSelect.Close()
Catch ex As Exception
lblErr.Text = ex.Message
Exit Sub
End Try
end sub
I am getting error at line with '***
Thanking you in advance.
Shail