Question : Procedure or function has too many arguments specified.

Hi,
I execute 2 procedures from Windows form in vb.net. After each is executed I should update my status table in databes with information that the same was exec OK (by exec Execution_flag sp) . For the first stored proc from the list everithing is OK (the same executed and the status table updated) . When I try to execute the second sp from the list the same is executed OK but when I try to update my status table (by executing "Execution_flag" sp)  I receive this error message (as in Title).
Please help me to solve the problem...
My code is below (breaks in line 26). Variable needed for execution of  Execution_flag is forwarded OK (the same represents stored porcedure name which last was executed).
Also, in addition please find my stored proc "Execution_flag":
ALTER PROCEDURE [dbo].[Execution_flag]
@stor_proc_name varchar(100)
AS
INSERT INTO SP_EXECUTION_TIMESTAMP
SELECT a.Name,a.object_id,a.type,a.type_desc,b.last_execution_time,b.last_worker_time as Execution_duration,'Y' as Execution_flag,
HOST_NAME() AS HostName, SUSER_NAME() LoggedInUser
FROM sys.objects as a JOIN sys.dm_exec_procedure_stats as b ON a.object_id = b.object_id
WHERE a.name = @stor_proc_name
Thank you...
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:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

        Dim bgw1 As BackgroundWorker = CType(sender, BackgroundWorker)
        Dim clbItems As List(Of String) = CType(e.Argument, List(Of String))
        Dim item As String

              Dim con As New SqlConnection(My.Settings.MyConnectionString)
        con.Open()
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        cmd.CommandTimeout = 0
        cmd.CommandType = CommandType.StoredProcedure
        Dim cmd1 As New SqlCommand()
        cmd1.Connection = con
        cmd1.CommandTimeout = 0
        cmd1.CommandType = CommandType.StoredProcedure

        For Each item In clbItems
                  bgw1.ReportProgress(0, item)
          
            cmd.CommandText = item
            cmd.ExecuteNonQuery()
            cmd1.CommandText = "Execution_flag"
            cmd1.Parameters.Add("@stor_proc_name", SqlDbType.NVarChar)
            cmd1.Parameters("@stor_proc_name").Value = item
            cmd1.ExecuteNonQuery()
        Next

              con.Close()
        

    End Sub

Answer : Procedure or function has too many arguments specified.

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:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

        Dim bgw1 As BackgroundWorker = CType(sender, BackgroundWorker)
        Dim clbItems As List(Of String) = CType(e.Argument, List(Of String))
        Dim item As String

              Dim con As New SqlConnection(My.Settings.MyConnectionString)
        con.Open()
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        cmd.CommandTimeout = 0
        cmd.CommandType = CommandType.StoredProcedure
        Dim cmd1 As New SqlCommand()
        cmd1.Connection = con
        cmd1.CommandTimeout = 0
        cmd1.CommandType = CommandType.StoredProcedure

            cmd1.CommandText = "Execution_flag"
            cmd1.Parameters.Add("@stor_proc_name", SqlDbType.NVarChar)

        For Each item In clbItems
                  bgw1.ReportProgress(0, item)
          
            cmd.CommandText = item
            cmd.ExecuteNonQuery()
            cmd1.Parameters("@stor_proc_name").Value = item
            cmd1.ExecuteNonQuery()
        Next

              con.Close()
        

    End Sub
Random Solutions  
 
programming4us programming4us