some people sometime have problems in this scenario, but not all the time, so why?
usually, when the SP's ParamList have the same params as the datacontrol(GridView etc.)'s databinding Fields(Plus DataKeyNames), they'll work perfectly. if not, this error message would show up.
for more info, please refer to:
1. How a Data Source Control Creates Parameters for Data-bound Fields:
here's a solution, only using "update" for example purpose, same as insert/delete:
in the <asp:SqlDataSource ...> section:
1. please make sure your code works fine with Non-SP situation, that means: UpdateCommandType="Text" UpdateCommand="UPDATE [TableName] SET [Param1]=@Param1, ...", will work fine.
2. make sure you have the same paramList declared in <UpdateParameters> section as your SP's paramList.
but they don't have to have the same paramList as your datacontrol bound fields( it can have more fields such as "description field", but you only want to update part of them, not all of them)
Add an event handle for your SqlDataSource's Updating event:
for example:
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
Hi, I am facing the same problem, I tried out so many times, without sp its working fine but with sp its creating the problem. Please check my code below, Am I missing anything?
It looks like you don't have your Insert Parameters declared in the markup. You declare the Select, Update, and Delete parameters but not the Insert params.
Uh Yea, I'm having this problem also, and I havent been able to resolve it. Could you please take a look at my code and see if you can see the problem.
<asp:SqlDataSource ID="sdsRetirementInfo"
runat="server" OnUpdating=sdsRetirementInfo_Updating
ConnectionString="<%$ ConnectionStrings:RetirementConnectionString %>"
SelectCommand="SELECT
RetirementInfo.retirementid, RetirementInfo.trf,
RetirementInfo.ssn, RetirementInfo.firstname, RetirementInfo.lastname,
RetirementInfo.retirementtype,
RetirementInfo.schoolid, RetirementInfo.counselorid,
[Type of Retirement].[Type of Retirement] AS Type_of_Retirement,
Schools.[School Code] + ' - ' + Schools.[School Unit] AS School,
Counselors.CounselorName
FROM RetirementInfo
LEFT OUTER JOIN [Type of Retirement] ON RetirementInfo.RetirementType = [Type of Retirement].[Type of Retirement ID]
LEFT OUTER JOIN Schools ON RetirementInfo.schoolid = Schools.[School ID]
LEFT OUTER JOIN Counselors ON RetirementInfo.counselorid = Counselors.Counselorid"
DeleteCommand="DELETE FROM RetirementInfo WHERE (retirementid = @retirementid)"
UpdateCommand="sp_UpdateRetirementInfo" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="retirementid" Type="Int32" />
<asp:Parameter Name="trf" Type="String"/>
<asp:Parameter Name="ssn" Type="String"/>
<asp:Parameter Name="firstname" Type="String"/>
<asp:Parameter Name="lastname" Type="String" />
<asp:Parameter Name="Retirementtype" Type="Int32" />
<asp:Parameter Name="schoolid" Type="Int32"/>
<asp:Parameter Name="counselorid" Type="Int32"/>
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="retirementid" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
if not exists(Select retirementid from retirementstatus where retirementid = @retirementid)
and not exists(Select retirementid from deceased where retirementid = @retirementid)
begin
if @retirementtype = 6
begin
INSERT INTO Deceased(retirementid, dte) values (@retirementid, getdate())
end
else
if @retirementtype > 0
begin
INSERT INTO RetirementStatus(retirementid, counselorassigned) values (@retirementid, getdate())
end
end
phynix
Member
375 Points
73 Posts
A solution for "Procedure or function has too many arguments specified" when you using SqlDataSou...
Jun 19, 2006 12:15 AM|LINK
some people sometime have problems in this scenario, but not all the time, so why?
usually, when the SP's ParamList have the same params as the datacontrol(GridView etc.)'s databinding Fields(Plus DataKeyNames), they'll work perfectly. if not, this error message would show up.
for more info, please refer to:
1. How a Data Source Control Creates Parameters for Data-bound Fields:
http://msdn2.microsoft.com/en-us/library/ms228051.aspx
2. Using Parameters with Data Source Controls:
http://msdn2.microsoft.com/en-us/library/xt50s8kz.aspx
3. How to troubleshoot 'Procedure or function has too many arguments specified' in asp.net 2.0:
http://www.whitworth.org/Blog/PermaLink,guid,ee69ddf8-3096-4818-abdb-0542d2fc191e.aspx
-------------------------------------------
here's a solution, only using "update" for example purpose, same as insert/delete:
in the <asp:SqlDataSource ...> section:
1. please make sure your code works fine with Non-SP situation, that means: UpdateCommandType="Text" UpdateCommand="UPDATE [TableName] SET [Param1]=@Param1, ...", will work fine.
2. make sure you have the same paramList declared in <UpdateParameters> section as your SP's paramList.
for example:
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="SalePrice" Type="Decimal" />
</UpdateParameters>
but they don't have to have the same paramList as your datacontrol bound fields( it can have more fields such as "description field", but you only want to update part of them, not all of them)
Add an event handle for your SqlDataSource's Updating event:
for example:
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
DbParameterCollection CmdParams = e.Command.Parameters;
ParameterCollection UpdParams = ((SqlDataSourceView)sender).UpdateParameters;
Hashtable ht = new Hashtable();
foreach (Parameter UpdParam in UpdParams)
ht.Add(UpdParam.Name, true);
for (int i = 0; i < CmdParams.Count; i++)
{
if (!ht.Contains(CmdParams[i].ParameterName.Substring(1)))
CmdParams.Remove(CmdParams[i--]);
}
}
They'll do the normalizing function for your passing-in parameters.
Hope this helpful ...
The Lost Link between Dream and Reality ...
F.Y.L
phynix
Member
375 Points
73 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Jun 20, 2006 12:28 AM|LINK
Revised #1:
1. Syntax for SP declared in <asp:SqlDataSource> section:
<asp:SqlDataSource ID="SqlDataSource1" ...
UpdateCommand="SP_Name" UpdateCommandType="StoredProcedure" OnUpdating="SqlDataSource1_Updating">
2. When you use your own code to prepare params rather than by datacontrol(gridview etc.), make sure don't define them twice, for example:
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="SalePrice" Type="Decimal" />
</UpdateParameters>
Params declared in this section will automatically be defined by ASP.NET, so don't define it in your code again, like:
SqlDataSource1.UpdateParameters.Add(new Parameter("ID", TypeCode.Int32));
<--this will cause define twice ! be careful. you don't need this statement.
SqlDataSource1.UpdateParameters["ID"].DefaultValue = "1";<--you can assign your param with a default value in your code, usually in the ing-events. you only need this assignment statement.
The Lost Link between Dream and Reality ...
F.Y.L
phynix
Member
375 Points
73 Posts
A solution for "Procedure or function has too many arguments specified" when you using SqlDataSou...
Jun 20, 2006 03:56 AM|LINK
3. using your own code to prepare params (e.Command.Parameters):
When you're in the ing-events, you can also access the e.Command.Parameters, they're the parameters the SqlDataSource will finally pass in to your SP.
1. using the trace code below to make sure what e.Command.Parameters you have right now:
<%@ Page Trace="true" ... %>
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
DbParameterCollection CmdParams = e.Command.Parameters;
foreach (DbParameter cp in CmdParams)
Trace.Warn(cp.ParameterName, cp.Value.ToString());
e.Cancel = true;
}
2. if you find out you're missing some params for your SP, or have more params than you need, then you can just add/remove them with:
Add/Insert Method:
SqlParameter myParam = new SqlParameter();
myParam.SqlDbType = SqlDbType.Int;
myParam.Direction= ParameterDirection.Input;
myParam.ParameterName="@ID";
myParam.Value=1;
e.Command.Parameters.Add(myParam);
// --- or ---
//e.Command.Parameters.Insert(iPos, myParam);
Remove Method:
e.Command.Parameters.RemoveAt("@ID");
That's all, No more mysteries.
The Lost Link between Dream and Reality ...
F.Y.L
Jay Khanpara
Member
85 Points
41 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Sep 25, 2007 06:26 AM|LINK
Hi, I am facing the same problem, I tried out so many times, without sp its working fine but with sp its creating the problem. Please check my code below, Am I missing anything?
<
asp:GridView ID="grdCalendar" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="Appointment" Style="position: static" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" DataKeyNames="AppointmentID" EmptyDataText = "No Appointment For Today" OnRowCommand="grdCalendar_RowCommand" > <Columns> <asp:BoundField DataField="AppointmentID" HeaderText="ID" Visible="False" /> <asp:TemplateField HeaderText="Title"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Detail"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Detail") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("Detail") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Date"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Date","{0:d}") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("Date","{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="From"> <EditItemTemplate> <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("From") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Bind("From") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="To"> <EditItemTemplate> <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("To") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label5" runat="server" Text='<%# Bind("To") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Priority"> <EditItemTemplate> <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Priority") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Bind("Priority") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> </Columns> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <EditRowStyle BackColor="#999999" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:SqlDataSource ID="Appointment" runat="server" ConnectionString="<%$ ConnectionStrings:ConString %>" DeleteCommand="spDeleteAppointment" DeleteCommandType="StoredProcedure" InsertCommand="spInsertAppointment" InsertCommandType="StoredProcedure" SelectCommand="spAppointmentByDate" SelectCommandType="StoredProcedure" UpdateCommand="spUpdateAppointment" UpdateCommandType="StoredProcedure"> <DeleteParameters> <asp:Parameter Name="AppID" Type="String" /> <asp:Parameter Name="EmpID" Type="String" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="AppID" Type="String" /> <asp:Parameter Name="EmpID" Type="String" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Detail" Type="String" /> <asp:Parameter Name="Date" Type="DateTime" /> <asp:Parameter Name="Type" Type="String" /> <asp:Parameter Name="To" Type="String" /> <asp:Parameter Name="From" Type="String" /> <asp:Parameter Name="Priority" Type="String" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="Calendar1" DefaultValue="" Name="date" PropertyName="SelectedDate" Type="DateTime" /> </SelectParameters>Thanks
Regards,
Jay Khanpara
Erik_with_a_...
Member
26 Points
18 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Dec 04, 2007 08:08 PM|LINK
It looks like you don't have your Insert Parameters declared in the markup. You declare the Select, Update, and Delete parameters but not the Insert params.
aw52741
Member
2 Points
1 Post
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Jan 18, 2008 03:41 PM|LINK
Uh Yea, I'm having this problem also, and I havent been able to resolve it. Could you please take a look at my code and see if you can see the problem.
<asp:SqlDataSource ID="sdsRetirementInfo"
runat="server" OnUpdating=sdsRetirementInfo_Updating
ConnectionString="<%$ ConnectionStrings:RetirementConnectionString %>"
SelectCommand="SELECT
RetirementInfo.retirementid, RetirementInfo.trf,
RetirementInfo.ssn, RetirementInfo.firstname, RetirementInfo.lastname,
RetirementInfo.retirementtype,
RetirementInfo.schoolid, RetirementInfo.counselorid,
[Type of Retirement].[Type of Retirement] AS Type_of_Retirement,
Schools.[School Code] + ' - ' + Schools.[School Unit] AS School,
Counselors.CounselorName
FROM RetirementInfo
LEFT OUTER JOIN [Type of Retirement] ON RetirementInfo.RetirementType = [Type of Retirement].[Type of Retirement ID]
LEFT OUTER JOIN Schools ON RetirementInfo.schoolid = Schools.[School ID]
LEFT OUTER JOIN Counselors ON RetirementInfo.counselorid = Counselors.Counselorid"
DeleteCommand="DELETE FROM RetirementInfo WHERE (retirementid = @retirementid)"
UpdateCommand="sp_UpdateRetirementInfo" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="retirementid" Type="Int32" />
<asp:Parameter Name="trf" Type="String"/>
<asp:Parameter Name="ssn" Type="String"/>
<asp:Parameter Name="firstname" Type="String"/>
<asp:Parameter Name="lastname" Type="String" />
<asp:Parameter Name="Retirementtype" Type="Int32" />
<asp:Parameter Name="schoolid" Type="Int32"/>
<asp:Parameter Name="counselorid" Type="Int32"/>
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="retirementid" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:GridView ID="gvRetirementInfo" runat="server" AutoGenerateColumns="False"
DataSourceID="sdsRetirementInfo" DataKeyNames="retirementid"
AllowPaging="True" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Vertical"
OnPageIndexChanged="gvRetirementInfo_PageIndexChanged"
AllowSorting="True" Font-Size="X-Small" Font-Names="Verdana"
OnSelectedIndexChanged="gvRetirementInfo_SelectedIndexChanged"
OnRowCancelingEdit="gvRetirementInfo_RowCancelingEdit"
OnRowDeleting="gvRetirementInfo_RowDeleting"
OnRowEditing="gvRetirementInfo_RowEditing">
<AlternatingRowStyle CssClass="AlternatingRowStyle" BackColor="Gainsboro" />
<RowStyle CssClass="RowStyle" BackColor="#EEEEEE" ForeColor="Black" />
<HeaderStyle CssClass="HeaderStyle" BackColor="#000084" Font-Bold="True"
ForeColor="White" />
<SelectedRowStyle CssClass="SelectedRowStyle" BackColor="#008A8C"
Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Select"
Text="Select"></asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick="return confirm('Are you sure you want to delete this record?');"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="retirementid">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("retirementid") %>'></asp:Label>
</EditItemTemplate>
<ControlStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("retirementid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TRF ID" SortExpression="trf">
<EditItemTemplate>
<asp:TextBox ID="EditTRF" runat="server"
Text='<%# Bind("[trf]") %>' Font-Size=X-Small
Font-Names="verdana" Width=48px></asp:TextBox>
<asp:RequiredFieldValidator runat=server
id=rfvEditTRF ControlToValidate=EditTRF
ErrorMessage="TRF Number is required field"
Text="* Required">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("[trf]") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SSN" SortExpression="ssn">
<EditItemTemplate>
<asp:TextBox ID="EditSSN" runat="server" Text='<%# Bind("ssn") %>' MaxLength="4"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEditSSN" runat=server
ControlToValidate="EditSSN"
ErrorMessage="You must enter last for digits of SSN"
Text="* Required field">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ControlStyle Font-Names="verdana" Font-Size="X-Small" Width="48px" />
<ItemStyle Wrap="False" />
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("ssn") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="EditFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID=rfvEditFirstName runat=server
ControlToValidate=EditFirstName
ErrorMessage="You must enter a first name for the member"
Text="* Required">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ControlStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name" SortExpression="LastName">
<EditItemTemplate>
<asp:TextBox ID="EditLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID=rfvEditLastName runat=server
ControlToValidate=EditLastName
ErrorMessage="You must enter a last name for the member"
Text="* Required">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ControlStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemStyle Font-Names="verdana" Font-Size="X-Small" />
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type of Retirement"
SortExpression="retirementtype">
<EditItemTemplate>
<asp:DropDownList ID="ddlEditretirementtype" runat="server"
DataSourceID="SqlDataSource4" DataTextField="Type_of_Retirement"
DataValueField="retirementtype" Font-Names="Verdana"
Font-Size="X-Small" SelectedValue='<%# Bind("retirementtype") %>'
AppendDataBoundItems="True"></asp:DropDownList>
<asp:RequiredFieldValidator ID=rfvddlEditretirementtype runat=server
ControlToValidate=ddlEditretirementtype
ErrorMessage="You must select a retirement type for the member"
Text="* Required">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ControlStyle Font-Names="Verdana" Font-Size="X-Small" />
<ItemStyle Font-Names="Verdana" Font-Size="X-Small" />
<HeaderStyle Font-Names="Verdana" Font-Size="X-Small" />
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("Type_of_Retirement") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="School" SortExpression="Schoolid">
<EditItemTemplate>
<asp:DropDownList ID="ddleditschool" DataSourceID="sqlDSSchool"
DataTextField="school" runat="server" Font-Size=X-Small
Font-Names="verdana" Width=276px
DataValueField="schoolid"
SelectedValue='<%# Bind("Schoolid") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server"
Text='<%# Bind("School") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Counselor" SortExpression="CounselorName">
<EditItemTemplate>
<asp:DropDownList ID="ddlEditCounselor" runat="server"
DataTextField="CounselorName" DataValueField="counselorid"
Font-Size=X-Small Font-Names="verdana" Width=115px
SelectedValue='<%# Bind("Counselorid") %>'
DataSourceID="SqlDSCounselors"></asp:DropDownList>
<asp:RequiredFieldValidator runat=server
id=rfvddlEditCounselor ControlToValidate=ddlEditCounselor
ErrorMessage="You must select a counselor for the member"
Text="* Required">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("CounselorName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
</asp:GridView>
Stored Procedure
ALTER PROCEDURE [dbo].[sp_UpdateRetirementInfo]
@retirementid int,
@trf nvarchar(7),
@ssn nvarchar(9),
@firstname nvarchar(75),
@lastname nvarchar(75),
@schoolid int,
@counselorid int,
@retirementtype int
AS
SET NOCOUNT OFF;
update RetirementInfo set trf = @trf, ssn = @ssn, firstname = @firstname ,
lastname = @lastname, schoolid = @schoolid, counselorid = @counselorid,
retirementtype = @retirementtype
where retirementid = @retirementid
if not exists(Select retirementid from retirementstatus where retirementid = @retirementid)
and not exists(Select retirementid from deceased where retirementid = @retirementid)
begin
if @retirementtype = 6
begin
INSERT INTO Deceased(retirementid, dte) values (@retirementid, getdate())
end
else
if @retirementtype > 0
begin
INSERT INTO RetirementStatus(retirementid, counselorassigned) values (@retirementid, getdate())
end
end
Jesus_Goku
Member
2 Points
1 Post
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
May 21, 2008 09:35 PM|LINK
Hello everybody...
I was trying and trying to solve this issue and finally i found the answer..
In my case, i only change the "Bind" method for "Eval" in designe mode.
Look and let me know if its works
avicool08
Member
710 Points
272 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Jun 02, 2008 06:15 AM|LINK
Your great.....its working fine....
Thanks [Yes]
Abinash Tumulu
Please mark my reply as an
answer
if it helps.
Visit my blog .net Scanner
wango
Member
98 Points
42 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Jun 17, 2008 02:22 PM|LINK
When I try to use the routine:
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
DbParameterCollection CmdParams = e.Command.Parameters;
ParameterCollection UpdParams = ((SqlDataSourceView)sender).UpdateParameters;
Hashtable ht = new Hashtable();
foreach (Parameter UpdParam in UpdParams)
ht.Add(UpdParam.Name, true);
for (int i = 0; i < CmdParams.Count; i++)
{
if (!ht.Contains(CmdParams[i].ParameterName.Substring(1)))
CmdParams.Remove(CmdParams[i--]);
}
}
I get the following error:
Error 2 No overload for 'ambassadorDetails_ItemInserting' matches delegate 'System.Web.UI.WebControls.DetailsViewInsertEventHandler' C:\WeDocs\FUND\AmbassadorEditUpdateNew.aspx 71 7 C:\WeDocs\FUND\
This is how my detailsview is defined:
<asp:DetailsView id="AmbassadorDetails" runat="server" AutoGenerateRows="False" AllowPaging="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateInsertButton="True" DataKeyNames="USAmbassadorID" DataSourceID="AmbassadorDataSource" OnItemUpdated="ambassadorDetails_ItemUpdated" OnItemDeleted="ambassadorDetails_ItemDeleted" OnItemInserted="ambassadorDetails_ItemInserted" OnItemInserting="ambassadorDetails_ItemInserting">...
...
<HeaderTemplate> <%#Eval("USAmbassadorLName") == null ? "Adding New Ambassador" :Eval(
"USAmbassadorLName")%> </HeaderTemplate> </asp:DetailsView>rajvi_25
Member
2 Points
2 Posts
Re: A solution for "Procedure or function has too many arguments specified" when you using SqlDat...
Aug 09, 2008 09:08 PM|LINK
[;) Yeah thats work for me( Bind to Eval)