473,883 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Too many args when running a stored procedure

M K
Heres my SP: ( i am trying to add more than 1 field but get the same error
no matter how many i try to add, i thought i would try to insert the primary
key only and work up from there but the primary key insert didnt work
either. I can run the SP manually in Visual Studio .NET and it works. When
i try to do this it doesn't.

Any help is greatly appreciated... newbie here as well so please be gentle
:)

ALTER PROCEDURE dbo.AddJob
@JobNumber varchar(30)
AS
INSERT INTO [Jobs].[dbo].[Job]
(JobRefNum)
VALUES
(@JobNumber)
Code:
SqlCommand1.Com mandType = CommandType.Sto redProcedure
SqlCommand1.Com mandText = "Jobs.dbo.AddJo b"
SqlCommand1.Par ameters.Add("@J obNumber", txtJobRefNumber .Text)
SqlCommand1.Exe cuteNonQuery()

Nov 21 '05
22 4307
Mark,

I'm glad to hear you got it working. I was completely out of suggestions.

--
Al Reid

"M K" <sk*******@yaho o.com> wrote in message
news:Xx******** ***********@twi ster.southeast. rr.com...
i guess theres something about SQLConnection that was messing me up.. heres
what now works.. need to tweek it but at least i got the insert to work..
Thanks a bunch Al!

I created the connection using the data object.. keeps from having to type
in the connection string .. it does it for you..

Again.. thanks!
Mark

Nov 21 '05 #21
It sounds like there might be an issue with the
..
..(partially omitted)
..
Or perhaps you should check the
..
..(partially omitted)
..
Best of
..
..(partially omitted)
..

"M K" <sk*******@yaho o.com> wrote in message
news:WQ******** ***********@twi ster.southeast. rr.com...
System.Data.Sql Client.SqlExcep tion: Procedure or function AddJob has too
many arguments specified at
.
.(partially omitted)
.
ExecuteReader(C ommandBehavior cmdBehavior, RunBehavior runBehavior,
Boolean returnStream)
.
.(partially omitted)
.
at JobBank.frmJobD etails.SaveToDb (String type) in D:. .
.\JobDetails.vb :line 417
"Michael C#" <xy*@abcdef.com > wrote in message
news:s_******** *********@fe12. lga...
What's the exact error message text you're receiving? Can we assume that
the SP is in the Jobs database as well? A lot of possible problems come
to mind, but without the exact code and DDL it's all guesswork.

"M K" <sk*******@yaho o.com> wrote in message
news:qL******** ***********@twi ster.southeast. rr.com...
Heres my SP: ( i am trying to add more than 1 field but get the same
error no matter how many i try to add, i thought i would try to insert
the primary key only and work up from there but the primary key insert
didnt work either. I can run the SP manually in Visual Studio .NET and
it works. When i try to do this it doesn't.

Any help is greatly appreciated... newbie here as well so please be
gentle :)

ALTER PROCEDURE dbo.AddJob
@JobNumber varchar(30)
AS
INSERT INTO [Jobs].[dbo].[Job]
(JobRefNum)
VALUES
(@JobNumber)
Code:
SqlCommand1.Com mandType = CommandType.Sto redProcedure
SqlCommand1.Com mandText = "Jobs.dbo.AddJo b"
SqlCommand1.Par ameters.Add("@J obNumber", txtJobRefNumber .Text)
SqlCommand1.Exe cuteNonQuery()



Nov 21 '05 #22
You're only passing in ten parameters, but I'm counting 11 in the procedure
declaration. Additionally you are potentially passing in a Zero-Length
String as a DATETIME value.

"M K" <sk*******@yaho o.com> wrote in message
news:ld******** ***********@twi ster.southeast. rr.com...
Did you see my first post?
I just tried creating a new SP within Visual Studio and I get the same
thing
Here is all the code that I am trying to run. It does work fine if i run
the SP in Server Explorer and it updates
the table just fine.

SP:
ALTER PROCEDURE dbo.AddAJob

(

@JobName varchar(50),

@JobNumber varchar(30),

@Contact varchar(40),

@Phone char(10),

@Fax char(10),

@MyDate datetime = GetDate,

@Location varchar(40),

@Skills text,

@Agency varchar(40),

@CloseDate datetime,

@Rate money

)

AS

INSERT INTO [Jobs].[dbo].[Job]

(JobName, JobRefNum, Contact, Phone, Fax, DateApplied, JobLocation,
Skills, Agency, CloseDate, Rate)

VALUES

(@JobName, @JobNumber, @Contact, @Phone, @Fax, @MyDate, @Location,
@Skills, @Agency, @CloseDate, @Rate)

RETURN
Code:

Try
SqlConnection1. Open()

'mandatory fields

SqlCommand1.Com mandType = CommandType.Sto redProcedure

SqlCommand1.Com mandText = "AddAJob"

SqlCommand1.Par ameters.Add("@J obName", txtJobName.Text )

SqlCommand1.Par ameters.Add("@J obNumber", txtJobRefNumber .Text)

SqlCommand1.Par ameters.Add("@C ontact", txtContact.Text )

SqlCommand1.Par ameters.Add("@P hone", txtPhone.Text)

If txtFax.Text <> "" Then

SqlCommand1.Par ameters.Add("@F ax", txtFax.Text)

Else

SqlCommand1.Par ameters.Add("@F ax", "")

End If

SqlCommand1.Par ameters.Add("@L ocation", txtLocation.Tex t)

SqlCommand1.Par ameters.Add("@S kills", txtSkills.Text)

SqlCommand1.Par ameters.Add("@A gency", txtAgency.Text)

'optional fields

If calCloseDate.Te xt <> "" Then

SqlCommand1.Par ameters.Add("@C loseDate", Format(calClose Date.Text,
"General Date"))

Else

SqlCommand1.Par ameters.Add("@C loseDate", "")

End If

If txtRate.Text <> "" Then

SqlCommand1.Par ameters.Add("@R ate", Format(txtRate. Text, "Currency") )

Else

SqlCommand1.Par ameters.Add("@R ate", "")

End If

SqlCommand1.Exe cuteNonQuery()

Catch ex As Exception

MsgBox("Could not add record" & Chr(10) & ex.ToString())

Exit Function

Finally

SqlConnection1. Close()

End Try
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:OV******** ******@TK2MSFTN GP12.phx.gbl...
MK,

Are you maybe adding the parameter to the parameterlist more times, this
is not unlikely because normally we would have seen an instrucktion as

\\\
SqlCommand1.Par ameters("@JobNu mber").value = xtJobRefNumber. Text
SqlCommand1.Exe cuteNonQuery()
///
I hope this helps,

Cor


Nov 21 '05 #23

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

Similar topics

5
6311
by: Boris Nikolaevich | last post by:
This is backwards of what I usually want--normally if you have a long-running ASP script, it's a good idea to check to see whether the client is still connected so you can cancel execution. However, I have a script that absolutely MUST finish one it's been started--is there a way to cause the entire script to execute, even if the client disconnects in the middle of the process? It doesn't matter if the script returns anything to the...
5
7301
by: Warren Wright | last post by:
Hi group, I have a select statement that if run against a 1 million record database directly in query analyzer takes less than 1 second. However, if I execute the select statement in a stored procedure instead, calling the stored proc from query analyzer, then it takes 12-17 seconds. Here is what I execute in Query Analyzer when bypassing the stored procedure:
1
7355
by: Private Pyle | last post by:
DB2 version 8, fixpack 5. Aix 5.1.0.0 Using C for AIX compiler. I'm having a problem where I can create stored procedures but I'm getting -444 when I call them. It's a new environment for running SP's so I wrote a very simple procedure just to make sure everything is working. Below is the db2set output for the SQLROUTINE_COMPILE_COMMAND, stored procedure text, log file, and result of a call. I'm getting an error that says function...
9
1655
by: John | last post by:
I have a single server running SQL Server 2000 sp3a, and acting as a ASP.NET webserver (.net 1.1 sp1). W2k sp4. Dual Xeon processor, 2 gigs RAM. Everything works fine, but sometimes when I execute a particular stored procedure (on server console using command line, nothing .net), my webapps will fail intermitently. Custom errors are turned on, so at this stage I can't give you error codes! But my assumption is that it's a SQL problem,...
4
5083
by: nate axtell | last post by:
In a VB .NET app I changed the text of a label then proceed to run a stored procedure which takes about 20 seconds. The label change doesn't show until after the stored procedure is finished. Is there a way to flush the label.text change right before the stored procedure call so that the text will be displayed to the user while the procedure is running? the "pseudo"code for what i have is: Label5.Visible = True Label5.Text = "Running...
7
3256
by: Jerry | last post by:
I'm trying to execute a stored procedure in a loop while paging through database table records but the stored procedure isn't running. I get the folowing error: The component 'adodb.connection' cannot be created. Apartment threaded components can only be created on pages with an <%@ Page aspcompat=true %> page directive. Can anyone tell me what I'm doing wrong? Below is my code. <%@ Import Namespace="System.Data" %> <%@ Import...
3
2937
by: =?Utf-8?B?YWJheWVy?= | last post by:
In short: I have an application using the CommittableTransaction class that works fine when run locally, but does not escalate to MSDTC when deployed to a Windows 2003 R2 server. More Specifically: I have a web service that saves data to a database. This service uses a CommittableTransaction to decide when to Commit or Abort the underlying
1
2659
by: Sureshbari | last post by:
Dear All, I have four table in database , each table contain the 5 lacs record, i have created a view on that four table using union clause. and now i am call that view form my code like select * form myview where name like '%Xya%' after that i am getting the memory fault .
0
1233
by: DR | last post by:
what are the memory caps for threads running as a CLR stored procedure executed by sql server 2005? is it limited by OS only or also by sql servers memory limits? e.g. lets say my clr stored procedure is executed by sql server 2005 then it creates 10 threads and each thread builds a giant array on the stack, is the limits of each array limited by sql server or the os? do these clr stored procedures run inside the sql server address space or...
0
9945
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
11157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10763
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
10863
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
10422
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
9586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5807
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...
0
6006
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
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

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.