Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   .NET (https://www.clubdelphi.com/foros/forumdisplay.php?f=17)
-   -   datareader (https://www.clubdelphi.com/foros/showthread.php?t=87710)

damian116 16-02-2015 04:31:37

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 


nlsgarcia 16-02-2015 05:17:08

damian116,

¡Bienvenido al Club Delphi! :D

Te sugiero revisar la Guía de estilo de los foros, recomendada a todos los nuevos ingresos al Club Delphi.

¡Gracias por tu cooperación! :) ^\||/

Saludos,

Nelson.


La franja horaria es GMT +2. Ahora son las 19:44:41.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi