ASP.NET - problema al cargar grid view

 
Vista:
sin imagen de perfil

problema al cargar grid view

Publicado por damian (1 intervención) el 16/02/2015 04:25:26
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

problema al cargar grid view

Publicado por Elmer (3 intervenciones) el 09/03/2015 07:00:38
Y si intentas esto:

If not IsPostBack Then
database.conectar()
LlenarCargoCombo()
Enf If

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar