I'm trying to learn SQL Server 2005 and ASP.NET 2.0. (I've been working with SQL 2000/.NET 1.1 until now.) I can't get past the following problem and hope one of you gurus can help:
The error I'm struggling with is: Procedure or function editArea has too many arguments specified.
NOte that this is a trimmed down version of the actual form page, which gets its ID from a GridView selection. That form also produces other errors, but I'm going to start with this error before tackling those.
The stored procedure follows:
Code:
ALTER PROCEDURE [dbo].[editArea]
[COLOR=green]
(
-- Add the parameters for the stored procedure here
@AreaId int,
@Name varchar(50),
@Description varchar(255) = NULL,
@ParentId int = NULL,
@TypeId tinyint,
@Enabled bit,
@original_Name varchar(50),
@original_Description varchar(255) = NULL,
@original_ParentId int = NULL,
@original_TypeId tinyint,
@original_Enabled bit,
@Error bit OUTPUT,
@Message varchar(255) OUTPUT
)[/color]
AS
BEGIN
[COLOR=red]-- I do a bunch of stuff, mostly checking for valid
-- input and update if valid, set
-- message and error parameters[/color]
[COLOR=green]RETURN [/color]
END
The Relevant section of the ASPX Page follows:
Code:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:FormView DefaultMode="Edit" ID="FormView1" runat="server" CellPadding="4"
DataKeyNames="AreaId" DataSourceID="SqlDataSource1" ForeColor="#333333">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<EditItemTemplate>
AreaId:
<asp:Label ID="AreaIdLabel1" runat="server" Text='<%# Eval("AreaId") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server"
Text='<%# Bind("Description") %>' />
<br />
Rank:
<asp:TextBox ID="RankTextBox" runat="server" Text='<%# Bind("Rank") %>' />
<br />
ParentId:
<asp:TextBox ID="ParentIdTextBox" runat="server"
Text='<%# Bind("ParentId") %>' />
<br />
TypeId:
<asp:TextBox ID="TypeIdTextBox" runat="server" Text='<%# Bind("TypeId") %>' />
<br />
Enabled:
<asp:CheckBox ID="EnabledCheckBox" runat="server"
Checked='<%# Bind("Enabled") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
[COLOR=green]<!-- There are also item/insert templates here, but removed for this post -->[/color]
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connString %>"
SelectCommand="SELECT AreaId, Name, Description, Rank, ParentId, TypeId, Enabled FROM Areas WHERE (AreaId = 2)"
UpdateCommand="editArea" UpdateCommandType="StoredProcedure">
[COLOR=green]
<UpdateParameters>
<asp:Parameter Name="AreaId" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="ParentId" Type="Int32" />
<asp:Parameter Name="TypeId" Type="Byte" />
<asp:Parameter Name="Enabled" Type="Boolean" />
<asp:Parameter Name="original_Name" Type="String" />
<asp:Parameter Name="original_Description" Type="String" />
<asp:Parameter Name="original_ParentId" Type="Int32" />
<asp:Parameter Name="original_TypeId" Type="Byte" />
<asp:Parameter Name="original_Enabled" Type="Boolean" />
<asp:Parameter Direction="InputOutput" Name="Error" Type="Boolean" />
<asp:Parameter Direction="InputOutput" Name="Message" Type="String" Size="255" />
</UpdateParameters>
</asp:SqlDataSource>[/color]
[COLOR=red]<!-- if I remove the output parameters, I get the following error:
"Procedure or function 'editArea' expects parameter '@Error', which was not supplied."
Also, changing direction to "Output" has no effect -->[/color]
The relevant section of ASPX.VB:
Code:
Protected Sub SqlDataSource1_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Updated
[COLOR=green]
Dim msg As String = Convert.ToString(e.Command.Parameters("@Message").Value)[/color]
label1.Text = msg
label1.Visible = True
End Sub