Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/05/2009, 09:32
colocha06
 
Fecha de Ingreso: mayo-2009
Mensajes: 5
Antigüedad: 15 años
Puntos: 0
Error al llamar a un procedimiento almacenado

Hola estoy desarrollando una aplicacion en vb.net 2005 y sql. Trato de utilizar Store Precedures y al llamarlo me avienta el error Object reference not set to an instance of an object.. El codigo es:

Private Sub BtnGuardar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click
Try

Dim ocmd As New SqlCommand("sp_dato", con)
ocmd.CommandType = CommandType.StoredProcedure
conexion.conexion()
Dim opara As New SqlParameter("@operacion", SqlDbType.Char) 'si recuerdas el parametro generado en sql @operacion
Dim op As New SqlParameter("@tipo", SqlDbType.VarChar)
opara.Size = 15 'tamaño de caracteres ha recibir el parametro
opara.Value = "ADD"
op.Size = 4
op.Value = Me.TxtCodDatos1.Text
ocmd.Parameters.Add(opara)
ocmd.Parameters.Add(op)

Da.SelectCommand = ocmd
Da.SelectCommand.Connection = con

Catch ex As Exception
'Me.TxtNumContrato.Text = ""
'Me.TxtNomTitular.Text = ""
'Me.TxtApeTitular.Text = ""
'Me.TxtNumContrato.Focus()
MsgBox("Datos no pudieron ser guardados", MsgBoxStyle.Exclamation = MsgBoxStyle.OkOnly, "ERROR")
con.Close()
End Try
End Sub