Estoy armando una pagina web me tira un error: connection must be valid and open,aparece cuando le doy click al boton buscar.El problema lo tengo en el datareader meparece
Código PHP:
Imports MySql.Data.MySqlClient
Public Class futbol5
Inherits System.Web.UI.Page
Dim database As New bd
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
database.conectar()
'Dim comando As New MySqlCommand
'Dim adaptador As New MySqlDataAdapter
If Not IsPostBack Then
LLenarCargoCombo()
End If
End Sub
Public Sub LLenarCargoCombo()
combozona.DataSource = database.ListarCargo
combozona.DataTextField = "nombre"
combozona.DataValueField = "idzona"
'actualizamos combobox'
combozona.DataBind()
End Sub
Public Sub llenardatagrid()
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles combozona.SelectedIndexChanged
End Sub
Protected Sub btnbuscar_Click(sender As Object, e As EventArgs) Handles btnbuscar.Click
Dim comando1 As New MySqlCommand
Try
comando1.Connection = bd.conn
comando1.CommandType = CommandType.StoredProcedure
comando1.CommandText = "buscar"
comando1.Parameters.Add(New MySqlParameter("ParamId", combozona.Text))
Dim dr3 As MySqlDataReader
dr3 = comando1.ExecuteReader()
Dim tabla3 As New DataTable
tabla3.Dispose()
tabla3.Load(dr3)
GridView1.DataSource = tabla3
GridView1.DataBind()
Catch ex As Exception
MsgBox(ex.Message)
Finally
End Try
End Sub
End Class