Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/12/2012, 05:07
maialenlopez
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
Exclamación Referencia a un objeto no establecida como instancia de un objeto

Hola;

Explico breve mente lo que hace este código
Código vb.net:
Ver original
  1. Imports System.Web
  2. Imports System.Web.Configuration
  3. Imports System.Data
  4. Imports System.Data.SqlClient
  5.  
  6.  
  7. Public Class Identificador
  8.     Inherits System.Web.UI.Page
  9.  
  10.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  11.  
  12.     End Sub
  13.  
  14. #Region "Propiedades"
  15.     Public ReadOnly Property Numero() As String
  16.         Get
  17.             Return Me.TxtIdNumIdentificador.Text
  18.         End Get
  19.     End Property
  20. #End Region
  21.  
  22.     Public Property MyProperty() As Integer
  23.         Get
  24.             Return m_MyProperty
  25.         End Get
  26.         Set(ByVal value As Integer)
  27.             m_MyProperty = Value
  28.         End Set
  29.     End Property
  30.  
  31.     Private m_MyProperty As Integer
  32.  
  33.     Protected Sub vaciarvalidaciones()
  34.  
  35.         validacion4.Text = ""
  36.         ValidacionAsterisco23.Text = ""
  37.     End Sub
  38.  
  39.     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  40.         Dim num As String
  41.  
  42.         Dim conn As New SqlConnection(WebConfigurationManager.ConnectionStrings("conexion").ConnectionString)
  43.  
  44.         vaciarvalidaciones()
  45.  
  46.         If TxtIdNumIdentificador.Text = "" Then
  47.             ValidacionAsterisco23.Text = "*"
  48.             validacion4.Text = "Identificador incorrecto"
  49.         Else
  50.  
  51.             Dim comm1 As SqlCommand = New SqlCommand("SELECT COUNT(*) " & _
  52.                                                 "FROM dbo.temp_datosGuardados " & _
  53.                                                 "WHERE id_identificador = @numidentificador", conn)
  54.             Dim reader1 As SqlDataReader
  55.  
  56.             Try
  57.                 With comm1
  58.                     .CommandType = CommandType.Text
  59.                     .Parameters.AddWithValue("numidentificador", CInt(TxtIdNumIdentificador.Text.Trim()))
  60.                 End With
  61.  
  62.                 Using conn
  63.  
  64.                     conn.Open()
  65.                     With comm1
  66.                         reader1 = .ExecuteReader()
  67.                         While reader1.Read()
  68.                             num = reader1.GetValue(0)
  69.                         End While
  70.                         .Dispose()
  71.                     End With
  72.                 End Using
  73.             Catch ex As Exception
  74.  
  75.                 MsgBox("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  76.                 'mensaje("Error en BD" & Chr(13) & Chr(13) & ex.Message)
  77.             Finally
  78.                 conn.Close()
  79.                 conn.Dispose()
  80.             End Try
  81.         End If
  82.  
  83.         If num = 0 Then
  84.  
  85.             ValidacionAsterisco23.Text = "*"
  86.             validacion4.Text = "* Numero de identificador de hoja incorrecto"
  87.         Else
  88.    [B]         Response.Redirect(String.Format("VRHojaLiquidacionGastos.aspx?number={0}", TxtIdNumIdentificador.Text))[/B]
  89.         End If
  90.     End Sub
  91. End Class
.

A la hora de darle al botón, manda el contenido del TxtIdNumIdentificador a la pagina VRHojaLiquidacionGastos.aspx para que desde esta se recoja ese valor. A la hora de ejecutar la linea marcada en negrita dentro del código que muestro me lanza un error de "Referencia a un objeto no establecida como instancia de un objeto".
Como puedo solucionar esto?

__________________
Gracias por todo;

Un saludo