Tema: Parámetros
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/05/2007, 12:13
Stream
 
Fecha de Ingreso: mayo-2004
Ubicación: Guadalajara, Jalisco, México
Mensajes: 724
Antigüedad: 20 años, 9 meses
Puntos: 6
Re: Parámetros

freegirl, deverias leerte el capitulo de acceso a datos.. creo que te falta leer algo por ahi...


Código:
  Private Function getText(ByVal campo2 As Integer) As String
        Dim result As String = ""
        Try
            Dim comm As New SqlCommand("select campo1 from tabla where campo2=@campo2", New SqlConnection(AppSettings("TuConnection")))
            comm.CommandType = CommandType.Text
            comm.Parameters.Add("@campo2", campo2)
            comm.Connection.Open()
            Dim reader As SqlDataReader = comm.ExecuteReader(CommandBehavior.CloseConnection)
			If reader.HasRows Then
				reader.Read
				result = reader("campo1") 
			End If
            reader.Close()
        Catch ex As Exception
        End Try
        Return result 
End Function
Y lo llamas asi..
Mitxt.text = getText(1)

Salu2