El procedimiento o la función "x" esperaba el parámetro "@x", que no se ha especif
Publicado por Luis (3 intervenciones) el 18/02/2014 23:14:31
Tengo un problema con un procedimiento al momento de ingresar datos a la base de datos, primeramente les comento que estoy utilizando Visual Basic Ultimate 2010 y para la base de datos Microsoft SQL Server Management Studio y quiero llevar a cabo la siguiente operacion de insertar datos y les paso el codigo que estoy utilizando y solo por ejemplo y para ver el problema solo lo estuve realizando con 2 campos o columnas.
CODIGO SQL
Y EL CODIGO VISUAL ES: (LO ESTOY MANEJANDO POR CAPAS YA TENGO UNA CLASE PARA LA CONEXION Y OTRA PARA MANDAR A LLAMAR EL PROCEDIMEINTO)
Y LA CONEXION CON LA BASE DE DATOS ES:
PERO CON TODO ESTO ME SALE EL SIGUIENTE ERROR Y YA ESTUVE REVISANDO Y NO ENCUENTRO DONDE PUEDA ESTAR EL PROBLEMA
El procedimiento o la función 'sptasasdeiva' esperaba el parámetro '@idtasasdeiva', que no se ha especificado
CODIGO SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
USE [BDActivos]
GO
/****** Object: StoredProcedure [dbo].[sptasasdeiva] Script Date: 02/10/2014 18:27:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sptasasdeiva]
@idtasasdeiva int,
@Nombretasasdeiva nvarchar(20)
AS
--insertar registros nuevos
begin
insert into ttasasdeiva(Nombretasasdeiva)
values (@Nombretasasdeiva)
end
1
2
3
4
5
6
7
8
9
10
11
12
Public Class DaoTasasdeIva
Dim db As New Conexion.Database
Public Sub Agregar(ByVal obj As ETasasdeIva)
Try
Dim arrParams As New ArrayList
arrParams.Add(New System.Data.SqlClient.SqlParameter("@accion", 1))
arrParams.Add(New System.Data.SqlClient.SqlParameter("@nombretasasdeiva", obj.NombreTasasdeIva))
db.ExecuteSP("sptasasdeiva", arrParams)
Catch ex As Exception
Throw ex
End Try
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Imports System.Data
Imports System.Data.SqlClient
Public Class Database
Dim connStr As String = "Data Source=LUISENRIQUE\SQLEXPRESS;Initial Catalog=BDActivos;Integrated Security=True"
Dim conn As New SqlConnection
Public Sub New()
conn.ConnectionString = connStr
End Sub
Public Sub OpenConnection()
Try
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Public Sub CloseConnection()
Try
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Public Function ExecuteSP(ByVal spName As String, ByVal params As ArrayList) As DataTable
Try
'crear comando
Dim command As New SqlCommand
command.CommandType = CommandType.StoredProcedure
command.CommandText = spName
command.CommandTimeout = 5
command.Connection = conn
For Each param As SqlParameter In params
command.Parameters.Add(param)
Next
'metodo de ejecución
Dim ds As New DataSet 'objeto creado vacio
Dim da As New SqlDataAdapter(command)
da.Fill(ds)
'asegurarnos de que se obtuvo una respuesta de la BD
If ds.Tables.Count > 0 Then
Return ds.Tables(0)
Else
Return Nothing
End If
Catch ex As Exception
Throw ex
End Try
End Function
Public Function ExecuteQuery(ByVal sql As String) As DataTable
Try
Dim command As New SqlCommand
command.CommandType = CommandType.Text
command.CommandText = sql
command.CommandTimeout = 5
command.Connection = conn
Dim ds As New DataSet
Dim da As New SqlDataAdapter(command)
da.Fill(ds)
If ds.Tables.Count > 0 Then
Return ds.Tables(0)
Else
Return Nothing
End If
Catch ex As Exception
Throw ex
End Try
End Function
Public Sub ExecuteNonQuery(ByVal sql As String)
Try
Dim command As New SqlCommand
command.CommandType = CommandType.Text
command.CommandText = sql
command.CommandTimeout = 5
command.Connection = conn
command.ExecuteNonQuery()
Catch ex As Exception
Throw ex
End Try
End Sub
El procedimiento o la función 'sptasasdeiva' esperaba el parámetro '@idtasasdeiva', que no se ha especificado
Valora esta pregunta


0