Tema: datareader
Ver Mensaje Individual
  #1  
Antiguo 16-02-2015
damian116 damian116 is offline
Registrado
NULL
 
Registrado: feb 2015
Posts: 1
Reputación: 0
damian116 Va por buen camino
datareader

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 

Última edición por nlsgarcia fecha: 16-02-2015 a las 05:14:38. Razón: Sintaxis e Indentación VB.Net
Responder Con Cita