Procedure or function sp_AddDealer has too many arguments specified.
I am experiencing the 'too many arguments specified' error. I am running on SQL 2005. The Parameters lists on SQL server (when I view a dropdown under the sp name) shows a 'returns integer' (but without the @ the signifies a parameter).
I have looked around the forums and haven't seen quite this flavor of this error. My forehead is sore from beating it against the wall... any clue would be appreciated!
The error occurs when I click the 'new' link button, enter some data and then click the update link button after ... BOOM - Procedure or function sp_AddDealer has too many arguments specified.
The visual studio 'configure data source' indeed forces the parameters to InputOutput. I did go in and hand tweak the generated ASP:datasource code and set them to output without altering my results. I was anticipating being able to test the returned values
in the insert_completed event.
It's odd to me that what I would consider to be the same functionality in CODE works, and this does not. It will certain add a lot of dev time if I cannot use form and SQLDatasource
The COLUMNS produced by the select query MUST match in name and quantity with the input parameters of the UpdateCommand. These select column names are used in the grid columns, and subsequently 'bound' to the named parameters in the Update command. So,
essentially, this error is resolved by modifying the stored procedures.
SET @nReturnCode = 0
SET @nReturnId = 0
SELECT
ISNULL(tblDealerGuideAssets.[_DealerGuideAssetsId],0) as [nDealerGuideAssetsId],
ISNULL(tblDealerGuideAssets.[Model Size],0) as [nModelSize],
ISNULL(tblDealerGuideAssets.[Assets],0) as nAsset,
ISNULL(tblDealerGuideAssets.[_DealerId],0) as [nDealerId]
FROM
tblDealerGuideAssets
WHERE
(tblDealerGuideAssets.[_DealerId] = @nDealerId)
ORDER BY
tblDealerGuideAssets.[Model Size]
SET @nReturnCode = 0
SET @nReturnId = 0
-----Udate --------------------------
sp_EditDealerGuideAssetByDealerGuideAssetsId]
@nDealerGuideAssetsId bigint,
@nDealerId bigint,
@nModelSize bigint,
@nAsset money,
@nReturnCode bigint output,
@nReturnId bigint output AS
SET @nReturnCode = 0
SET @nReturnId = 0
DECLARE @m_nCt bigint
BEGIN
UPDATE
tblDealerGuideAssets
SET
[_DealerId] = @nDealerId, [Model Size] = @nModelSize, [Assets] = @nAsset
WHERE
([_DealerGuideAssetsId] = @nDealerGuideAssetsId)
SET @nReturnCode = 0
SET @nReturnId = @nDealerGuideAssetsId
two other points: running the 'configure' wizard seems to reset the parameter directions. I found it was necessary to edit the ASP to ensure that all the
Direction="Input" and Direction="Output" were explicit
ckigar
0 Points
4 Posts
Procedure or function sp_AddDealer has too many arguments specified (error via SqlDataSource)
Apr 09, 2007 10:37 PM|LINK
Procedure or function sp_AddDealer has too many arguments specified.
I am experiencing the 'too many arguments specified' error. I am running on SQL 2005. The Parameters lists on SQL server (when I view a dropdown under the sp name) shows a 'returns integer' (but without the @ the signifies a parameter).
I have looked around the forums and haven't seen quite this flavor of this error. My forehead is sore from beating it against the wall... any clue would be appreciated!
The error occurs when I click the 'new' link button, enter some data and then click the update link button after ... BOOM - Procedure or function sp_AddDealer has too many arguments specified.
Thanks!!
Chip Kigar
Here is the stored Procedure:
Here is the SQLDataSource. I plugged the ID parameter, so I got a schema back, but no data.
Here is the Formview:
Stored Procedures SqlDataSource
busyweb
Member
706 Points
121 Posts
Re: Procedure or function sp_AddDealer has too many arguments specified (error via SqlDataSource)
Apr 10, 2007 01:57 AM|LINK
Hello,
I wonder why these two parameter direction is InputOutput, it should be Output???
<asp:Parameter Direction="InputOutput" Name="nReturnCode" Type="Int64" />
<asp:Parameter Direction="InputOutput" Name="nReturnId" Type="Int64" />
Is it made by Visual Studio?
for InputOutput direction, stored procedure expects any input value from caller, at least Default Value ..
Why don't you try add default value for these parameters like DBNull.value or 0(zero).
Or you can set the default value on your Insert Stored Procedure.
ALTER PROCEDURE [dbo].[sp_AddDealer] @sCarcareSystem varchar(100),
@sDealerName varchar(50),
@sDealerPhysAddrStreet varchar(200),
@sDealerPhysAddrCity varchar(100),
@sDealerPhysAddrState varchar(10),
@sDealerPhysAddrZip varchar(20),
@nReturnCode bigint = null output,
@nReturnId bigint = null output AS
Try, and let me know how you solved. Curious!!
ckigar
0 Points
4 Posts
Re: Procedure or function sp_AddDealer has too many arguments specified (error via SqlDataSource)
Apr 10, 2007 02:18 AM|LINK
The visual studio 'configure data source' indeed forces the parameters to InputOutput. I did go in and hand tweak the generated ASP:datasource code and set them to output without altering my results. I was anticipating being able to test the returned values in the insert_completed event.
It's odd to me that what I would consider to be the same functionality in CODE works, and this does not. It will certain add a lot of dev time if I cannot use form and SQLDatasource
ckigar
0 Points
4 Posts
Re: Procedure or function sp_AddDealer has too many arguments specified (error via SqlDataSource)
Apr 12, 2007 02:09 PM|LINK
The answer:
The COLUMNS produced by the select query MUST match in name and quantity with the input parameters of the UpdateCommand. These select column names are used in the grid columns, and subsequently 'bound' to the named parameters in the Update command. So, essentially, this error is resolved by modifying the stored procedures.
For example:
-----Select Query--------------------
sp_GetDealerGuideAssetsByDealerId] @nDealerId bigint, @nReturnCode bigint output, @nReturnId bigint output AS
SET @nReturnCode = 0
SET @nReturnId = 0
SELECT
ISNULL(tblDealerGuideAssets.[_DealerGuideAssetsId],0) as [nDealerGuideAssetsId],
ISNULL(tblDealerGuideAssets.[Model Size],0) as [nModelSize],
ISNULL(tblDealerGuideAssets.[Assets],0) as nAsset,
ISNULL(tblDealerGuideAssets.[_DealerId],0) as [nDealerId]
FROM
tblDealerGuideAssets
WHERE
(tblDealerGuideAssets.[_DealerId] = @nDealerId)
ORDER BY
tblDealerGuideAssets.[Model Size]
SET @nReturnCode = 0
SET @nReturnId = 0
-----Udate --------------------------
sp_EditDealerGuideAssetByDealerGuideAssetsId]
@nDealerGuideAssetsId bigint,
@nDealerId bigint,
@nModelSize bigint,
@nAsset money,
@nReturnCode bigint output,
@nReturnId bigint output AS
SET @nReturnCode = 0
SET @nReturnId = 0
DECLARE @m_nCt bigint
BEGIN
UPDATE
tblDealerGuideAssets
SET
[_DealerId] = @nDealerId, [Model Size] = @nModelSize, [Assets] = @nAsset
WHERE
([_DealerGuideAssetsId] = @nDealerGuideAssetsId)
SET @nReturnCode = 0
SET @nReturnId = @nDealerGuideAssetsId
two other points: running the 'configure' wizard seems to reset the parameter directions. I found it was necessary to edit the ASP to ensure that all the Direction="Input" and Direction="Output" were explicit
<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Dealer.Master" CodeBehind="DealerAssets.aspx.vb" Inherits="hrs2.WebForm16"
title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label" Width="249px"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HRS Fast AccessConnectionString %>"
SelectCommand="sp_GetDealerAssetsByDealerId" SelectCommandType="StoredProcedure"
UpdateCommand="sp_EditDealerAssetByDealerGuideAssetsId" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Direction="Input" Name="nDealerGuideAssetsId" Type="Int64" />
<asp:Parameter Direction="Input" Name="nDealerId" Type="Int64" />
<asp:Parameter Direction="Input" Name="nModelSize" Type="Int64" />
<asp:Parameter Direction="Input" Name="nAsset" Type="Decimal" />
<asp:Parameter Direction="Output" Name="nReturnCode" Type="Int64" />
<asp:Parameter Direction="Output" Name="nReturnId" Type="Int64" />
</UpdateParameters>
<SelectParameters>
<asp:Parameter Direction="Input" DefaultValue="24" Name="nDealerId" Type="Int64" />
<asp:Parameter Direction="Output" Name="nReturnCode" Type="Int64" />
<asp:Parameter Direction="Output" Name="nReturnId" Type="Int64" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="nDealerGuideAssetsId,nDealerId">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="nDealerGuideAssetsId" HeaderText="nDealerGuideAssetsId" ReadOnly="True" SortExpression="nDealerGuideAssetsId" />
<asp:BoundField DataField="nDealerId" HeaderText="nDealerId" ReadOnly="True" SortExpression="nDealerId" />
<asp:BoundField DataField="nModelSize" HeaderText="nModelSize" SortExpression="nModelSize" />
<asp:BoundField DataField="nAsset" HeaderText="nAsset" ReadOnly="True" SortExpression="nAsset" />
</Columns>
</asp:GridView>
</asp:Content>
mcupryk
Member
243 Points
394 Posts
Re: Procedure or function sp_AddDealer has too many arguments specified (error via SqlDataSource)
Aug 01, 2012 01:27 PM|LINK
Can u help me with http://forums.asp.net/p/1829050/5091410.aspx/1?p=True&t=634794096147336323