Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/12/2012, 13:04
Avatar de ana_gloria
ana_gloria
 
Fecha de Ingreso: febrero-2008
Mensajes: 65
Antigüedad: 16 años, 2 meses
Puntos: 1
Problema con variable de excepcion en procedimiento almacenado

Buenas tardes, resulta que estoy haciendo una aplicación por medio de visual basic.net y sql server 2008, en sql server he hecho el siguiente PA para que me registre un nuevo usuario, utilizo 2 tablas ya que en una guarda el nivel y area a la q pertenecera una vez insertado ahi jalo el ID y en la otra tabla guardo los demás datos junto con el ID:

Código:
USE [seder]
GO
/****** Object:  StoredProcedure [dbo].[nvousuario]    Script Date: 12/06/2012 15:52:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
---nvousuario
ALTER proc [dbo].[nvousuario]
@nombre_desplegar nchar(15),
@usuario nchar(15),
@pass nchar(15),
@titulo nchar(10),
@apep nchar(15),
@apem nchar(15),
@nombre nchar(15),
@email nchar(15),
@telefono_of nchar(15),
@cel1 nchar(15),
@cel2 nchar(15),
@nivel nchar(15),
@area nchar(15),
@id_nivel int

AS
-- Parámetros de salida
DECLARE @msg1 varchar(255)

BEGIN
SET NOCOUNT ON;

  Begin Tran Tadd

  Begin Try
	
	INSERT INTO tbl_nivel_area(nivel, area)VALUES(@nivel, @area)
	SELECT @@IDENTITY as id_nivel
	
	INSERT INTO tbl_usuario(nombre_desplegar, email, usuario, pass, titulo,apep, apem, nombre,
	 telefono_of, cel1, cel2, id_na)
	VALUES(@nombre_desplegar, @email, @usuario, @pass, @titulo, @apep, @apem, @nombre,
	 @telefono_of, @cel1, @cel2, @id_nivel)	
	
	
		SET @msg1 = 'El usuario se registro correctamente.'
		

       COMMIT TRAN Tadd
  End try
  Begin Catch

        SET @msg1 = 'Ocurrio un Error: ' + ERROR_MESSAGE() + ' en la línea ' + CONVERT(NVARCHAR(255), ERROR_LINE() ) + '.'
        Rollback TRAN Tadd

  End Catch

END


y al momento de ejecutar me sale el siguiente error:

Procedure or Function 'nvousuario' expects parameter '@msg1', which was not supplied


aqi les dejo el codigo q tengo en el boton que me GUARDA EL NVO USUARIO:

Código:
Imports System.Data.SqlClient
Imports System.Data
Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cmd As SqlCommand
        Dim dr As SqlDataReader
        Try
            'abrir la conexion
            con.Open()
            cmd = New SqlCommand("nvousuario", con)
            cmd.CommandType = 4
            With cmd.Parameters
                .AddWithValue("@nombre_desplegar", nombre_desplegar.Text.ToString)
                .AddWithValue("@usuario", usuario.Text.ToString)
                .AddWithValue("@pass", pass.Text.ToString)
                .AddWithValue("@titulo", titulo.Text.ToString)
                .AddWithValue("@apep", apep.Text.ToString)
                .AddWithValue("@apem", apem.Text.ToString)
                .AddWithValue("@nombre", nombre.Text.ToString)
                .AddWithValue("@email", email.Text.ToString)
                .AddWithValue("@telefono_of", telefono_of.Text.ToString)
                .AddWithValue("@cel1", cel1.Text.ToString)
                .AddWithValue("@cel2", cel2.Text.ToString)
                .AddWithValue("@nivel", nivel.Text.ToString)
                .AddWithValue("@area", area.Text.ToString)
            End With

            dr = cmd.ExecuteReader
            If dr.HasRows = True Then
                MsgBox("El usuario se registro exitosamente", vbInformation)

            Else
                MsgBox("No se pudo guardar el usuario..", vbInformation)
                nombre_desplegar.Text =
                usuario.Text =
                nombre_desplegar.Text =
                usuario.Text =
                pass.Text =
                titulo.Text =
                apep.Text =
                apem.Text =
                nombre.Text =
                email.Text =
                telefono_of.Text =
                cel1.Text =
                cel2.Text =
                nombre_desplegar.Focus()
            End If
        Catch ex As Exception : MsgBox(ex.Message)

        End Try
        con.Close()
    End Sub

End Class



cualqier orientación les estoy muy agradecida ....
__________________
UN PUEBLO IGNORANTE, ES INSTRUMENTO DE SU PROPIA DESTRUCCIÓN...