473,769 Members | 4,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored procedure error:

Hi, I am getting the error: "Procedure or function spAddActivity has too
many arguments specified. " on a stored procedure insert. I compared the
number of parameters in the function and the SP and they match. I compared
the type of the parameters and they match. I then made sure that everything
I wasn't inserting allowed nulls. The error persists. What else could
this be? Code and SP below. Its possible that I am stupid and missing the
obvious (due to give birth any minute and brain not quite as adept as
normal).

Thanks in advance!

Error: Procedure or function spAddActivity has too many arguments
specified.

Code:
Public Shared Function AddActivity(ByV al myActivity As Activity) As Integer

Dim conTA As New SqlConnection
Dim SInsert As String
Dim AddActSuccess As Boolean

conTA.Connectio nString =
ConfigurationSe ttings.AppSetti ngs("Connection String")
Dim cmdActivity As New SqlCommand
cmdActivity.Com mandType = CommandType.Sto redProcedure
cmdActivity.Com mandText = "spAddActiv ity"
cmdActivity.Con nection = conTA
cmdActivity.Par ameters.Add("@o rgid", myActivity.OrgI D)
If myActivity.Indi vidualID = 0 Then
cmdActivity.Par ameters.Add("@i ndividualid", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@i ndividualid", myActivity.Indi vidualID)
End If
cmdActivity.Par ameters.Add("@a pcauser", myActivity.APCA User)
cmdActivity.Par ameters.Add("@a ctivitydescript ion",
myActivity.Desc ription)cmdActi vity.Parameters .Add("@individu alid",
myActivity.Indi vidualID)
If myActivity.Acti vityDate = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@A ctivityDate", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@A ctivityDate", myActivity.Acti vityDate)
End If
cmdActivity.Par ameters.Add("@t a", myActivity.TA)
If myActivity.Type TA = 0 Then
cmdActivity.Par ameters.Add("@t ypeta", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@t ypeta", myActivity.Type TA)
End If
If myActivity.Eval Requested = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@e valrequested", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@e valrequested", myActivity.Eval Requested)
End If
If myActivity.Eval Completed = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@e valcompleted", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@e valcompleted", myActivity.Eval Completed)
End If

If myActivity.TACa tegory = 0 Then
cmdActivity.Par ameters.Add("@t acategory", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@t acategory", myActivity.TACa tegory)
End If
conTA.Open()
AddActSuccess = True
Try
cmdActivity.Exe cuteNonQuery()
Catch ex As Exception
AddActSuccess = False
'End Try
conTA.Close()
Return AddActSuccess
End Function


Stored Procedure:
CREATE PROCEDURE spAddActivity

@orgid as integer,
@individualid as integer,
@apcauser as varchar(50),
@activitydescri ption as ntext,
@activitydate as datetime,
@TA as bit,
@typeTA as integer,
@evalrequested as datetime,
@evalcompleted as datetime,
@tacategory as integer

AS
begin transaction

insert into tblActivities
(org, person, [user], activitydescrip tion, activitydate,
technicalassist ance, typeta, evalrequested, evalcompleted, tacategory)
values
(@orgid, @individualid, @apcauser, @activitydescri ption, @activitydate,
@TA, @typeTA, @evalrequested, @evalcompleted, @tacategory)

If @@Error <> 0
BEGIN
ROLLBACK TRAN
RETURN

END
COMMIT TRANSACTION
GO
Nov 19 '05 #1
1 1373
Hi Child,

You've added "@individua lid" twice. First, conditionally, second
unconditionally :
If myActivity.Indi vidualID = 0 Then
cmdActivity.Par ameters.Add("@i ndividualid", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@i ndividualid", myActivity.Indi vidualID)
End If
....
myActivity.Desc ription)cmdActi vity.Parameters .Add("@individu alid",
myActivity.Indi vidualID)
An easy mistake to make, and a hard one to find, so don't be hard on
yourself.

BTW, here's how I found it (and it wasn't easy!):

First, I counted the number of parameters in your SP. Then I counted the
number of additions of parameters in your code. In the query I came up with
10, after counting a couple of times to make sure. In the code, which was a
bit harder due to the conditional statements, I counted 11. I then had to
read through the code several times to find the duplicate (which, because it
was a duplicate, was rather hard to identify).

One way to avoid this in the future would be to put the addition of the
parameters in your code in the same order as the parameter list in the
query. You came close, but the order was a bit mixed up near the beginning.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Child" <Sp**********@a laska.com> wrote in message
news:11******** *****@corp.supe rnews.com... Hi, I am getting the error: "Procedure or function spAddActivity has too
many arguments specified. " on a stored procedure insert. I compared the
number of parameters in the function and the SP and they match. I
compared the type of the parameters and they match. I then made sure that
everything I wasn't inserting allowed nulls. The error persists. What
else could this be? Code and SP below. Its possible that I am stupid
and missing the obvious (due to give birth any minute and brain not quite
as adept as normal).

Thanks in advance!

Error: Procedure or function spAddActivity has too many arguments
specified.

Code:
Public Shared Function AddActivity(ByV al myActivity As Activity) As
Integer

Dim conTA As New SqlConnection
Dim SInsert As String
Dim AddActSuccess As Boolean

conTA.Connectio nString =
ConfigurationSe ttings.AppSetti ngs("Connection String")
Dim cmdActivity As New SqlCommand
cmdActivity.Com mandType = CommandType.Sto redProcedure
cmdActivity.Com mandText = "spAddActiv ity"
cmdActivity.Con nection = conTA
cmdActivity.Par ameters.Add("@o rgid", myActivity.OrgI D)
If myActivity.Indi vidualID = 0 Then
cmdActivity.Par ameters.Add("@i ndividualid", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@i ndividualid", myActivity.Indi vidualID)
End If
cmdActivity.Par ameters.Add("@a pcauser", myActivity.APCA User)
cmdActivity.Par ameters.Add("@a ctivitydescript ion",
myActivity.Desc ription)cmdActi vity.Parameters .Add("@individu alid",
myActivity.Indi vidualID)
If myActivity.Acti vityDate = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@A ctivityDate", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@A ctivityDate", myActivity.Acti vityDate)
End If
cmdActivity.Par ameters.Add("@t a", myActivity.TA)
If myActivity.Type TA = 0 Then
cmdActivity.Par ameters.Add("@t ypeta", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@t ypeta", myActivity.Type TA)
End If
If myActivity.Eval Requested = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@e valrequested", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@e valrequested", myActivity.Eval Requested)
End If
If myActivity.Eval Completed = DateTime.MaxVal ue Then
cmdActivity.Par ameters.Add("@e valcompleted", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@e valcompleted", myActivity.Eval Completed)
End If

If myActivity.TACa tegory = 0 Then
cmdActivity.Par ameters.Add("@t acategory", DBNull.Value)
Else
cmdActivity.Par ameters.Add("@t acategory", myActivity.TACa tegory)
End If
conTA.Open()
AddActSuccess = True
Try
cmdActivity.Exe cuteNonQuery()
Catch ex As Exception
AddActSuccess = False
'End Try
conTA.Close()
Return AddActSuccess
End Function


Stored Procedure:
CREATE PROCEDURE spAddActivity

@orgid as integer,
@individualid as integer,
@apcauser as varchar(50),
@activitydescri ption as ntext,
@activitydate as datetime,
@TA as bit,
@typeTA as integer,
@evalrequested as datetime,
@evalcompleted as datetime,
@tacategory as integer

AS
begin transaction

insert into tblActivities
(org, person, [user], activitydescrip tion, activitydate,
technicalassist ance, typeta, evalrequested, evalcompleted, tacategory)
values
(@orgid, @individualid, @apcauser, @activitydescri ption, @activitydate,
@TA, @typeTA, @evalrequested, @evalcompleted, @tacategory)

If @@Error <> 0
BEGIN
ROLLBACK TRAN
RETURN

END
COMMIT TRANSACTION
GO

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
22146
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
3
2805
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
0
4278
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the experts here agree with the following? Would they add any other points? 1. If the shop standard calls for logging of application errors, a stored procedure should log any error that it encounters immediately upon detecting it and then return to the...
4
3191
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method signature for the stored procedure included: Throwable throwable
2
9244
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
1
13669
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start procedure============= Create PROCEDURE get_timedout_scripts (
7
9716
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
7
5842
by: eholz1 | last post by:
Hello PHP group, Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0 running on Linux (Redhat Fedora Core 6). All that works fine. I would like to be able to "call" a stored procedure from a PHP program, and run a stored procedure. I have yet to figure out the proper way to do this. My stored procedures work fine from the mysql command line using syntax: "call sp_min_record (101);"
4
5077
by: barmatt80 | last post by:
I am stumped on the error reporting with sql server. I was told i need to return @SQLCode(code showing if successful or not) and @ErrMsg(and the message returned). I am clueless on this. I wrote this procedure: ALTER PROCEDURE . @Emp_SSN int, @Annual_Forward decimal(10,2),
0
3192
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works fine. Now we decided to move from mainframe IMS-DB2 to Windows 2003 server-DB2 UDB for LUW 9.5.
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.