No me sale

25/01/2005 - 22:12 por Susana | Informe spam
No me sale por favor
ayudame

Me.SqlSelectCommand1.CommandText = "SELECT * FROM CLIENTE
where NOMBRE LIKE '%" & Me.txtnombre.Text & "%' "
Me.SqlSelectCommand1.Connection =
Me.SqlConnection1
Me.SqlDataAdapter1.SelectCommand =
Me.SqlSelectCommand1
Me.SqlDataAdapter1.Fill(Me.DataSet11)
If DataSet11 Is Nothing Then
DataGrid1.Visible = False
Else
DataGrid1.Visible = True
Me.DataGrid1.DataSource = Me.DataSet11
Me.DataGrid1.DataBind()

Preguntas similare

Leer las respuestas

#1 Misael Monterroca
25/01/2005 - 22:29 | Informe spam
Prueba lo siguiente


If DataSet11.Tables.Count = 0 Then
DataGrid1.Visible = False
Else
DataGrid1.Visible = True
Me.DataGrid1.DataSource = Me.DataSet11
Me.DataGrid1.DataBind()



Saludos!
Misael Monterroca
http://www.neo-mx.com/blog
Respuesta Responder a este mensaje
#2 Eduardo A. Morcillo [MS MVP VB]
25/01/2005 - 22:32 | Informe spam
Fill no crea el dataset sino que lo creas tu en codigo, por lo tanto nunca
sera Nothing. Y como estas cargando un datagrid de asp lo mejor seria usar
un DataReader (y ademas, usar parametros en la consulta). Ejemplo:

Dim cmd As New SqlCommand
Dim reader As SqlDataReader

cmd.CommandText = "SELECT * FROM Cliente WHERE Nombre LIKE '%'+ @Nombre
+'%'"
cmd.Connection = cnx
cmd.Parameters.Add("@Nombre", Me.txtnombre.Text)

Try

' Abro la conexion
cnx.Open()

' Ejecuto la consulta
reader = cmd.ExecuteReader()

' Devolvio alguna fila?
If reader.HasRows Then
DataGrid1.DataSource = reader
DataGrid1.DataBind()
Else
DataGrid1.Visible = False
End If

Finally

' Cierro el reader y la conexion
If Not reader Is Nothing Then reader.Close()
cnx.Close()

End Try

Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo

Inteligencia militar son dos términos contradictorios.
Groucho Marx
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida