[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Trying to fix "Too Many Aguments Specified" error

Asked by SeTech in Programming for ASP.NET, Visual Studio, SQL Server 2005

Tags: ASP.Net

I've got an ASP.Net 2.0 web app, connected to a SQL Server 2005 database, that is giving me some trouble. I've got a GridView that contains a number of columns...only 4 of them are editable, so for the sake of space, I will only show the 4. Here is the GridView declaration :

<asp:GridView id="gvResult" runat="server" Width="100%" CssClass="salesdirgrid"
            AllowPaging="True" CellPadding="1" AllowSorting="True"
            OnPageIndexChanging="gvResult_PageIndexChanging" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="Terr,Mkt,Agtno5,Fname,Lname,DBA,Street,City,State,Zip,Booth,EmplDate,TermDate,PrefPhone,Ceasar,County,ACT,Sat_Type">
                              <Columns>
                [...]
                <asp:TemplateField HeaderText="First Name" SortExpression="[FName]">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtFname" Text='<%# Bind("FName") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblFname" Text='<%# Eval("FName") %>' runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Last Name" SortExpression="[LName]">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtLname" Text='<%# Bind("LName") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblLname" Text='<%# Eval("LName") %>' runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                [...]
                <asp:TemplateField HeaderText="Ceasar" SortExpression="[Ceasar]">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCeasar" Text='<%# Bind("Ceasar") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCeasar" Text='<%# Eval("Ceasar") %>' runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="County" SortExpression="[County]">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCounty" Text='<%# Bind("County") %>' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCounty" Text='<%# Eval("County") %>' runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                [...]
            </Columns>
            </asp:GridView>
=================================================================
I am trying to use a SqlDataSource and Stored Procedures to work with the GridView. The Select procedure works perfectly, but it's the Update SP that's amiss. Here's the info from the SqlDataSource :

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:salesdir %>"
        SelectCommand="sp_getData" SelectCommandType="StoredProcedure" UpdateCommand="sp_editAgentInfo" UpdateCommandType="StoredProcedure">
        <UpdateParameters>
            <asp:Parameter Name="AgtNo" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="Caesar" Type="String" />
            <asp:Parameter Name="County" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlUserType" Name="type" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="ddlRegion" Name="region" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="ddlStatus" Name="status" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="ddlSearchBy" Name="search" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="txtPanel" Name="input" PropertyName="Text" Type="String" ConvertEmptyStringToNull="False" />
        </SelectParameters>
    </asp:SqlDataSource>
==========================================================
And here is the SP, which as you can see, the parameters match the UpdateParameters :

ALTER PROCEDURE [dbo].[sp_editAgentInfo]
@AgtNo char(6),
@FirstName varchar (100),
@LastName varchar (100),
@Caesar char(6),
@County varchar(25)
AS
SET NOCOUNT ON

UPDATE tblAgtUpdate
SET FName = @FirstName, LName = @LastName, Ceasar = @Caesar, County = @County
WHERE Agtno LIKE '%' + @AgtNo
=======================================================
Now, when I got the error, I naturally searched EE here, and I found other people were getting results by using the Sql Profiler, so I tried that. I am quite confused, however, as the entry for the query came out to be :

exec sp_editAgentInfo @AgtNo=NULL,@FirstName=NULL,@LastName=NULL,@Caesar=NULL,@FName=N'Jesse',@LName=N'Wisdom',@Ceasar=N'Y74134',@County=N'Lauderdale',@Terr=N'D',@Mkt=N'11',@Agtno5=N'04228',@DBA=N' J Wisdom Ins Agy',@Street=N'206 A Cox Creek Pkwy',@City=N'Florence',@State=N'AL',@Zip=N'35630',@Booth=N'AL29A',@EmplDate='1998-09-06 00:00:00:000',@TermDate=NULL,@PrefPhone=2567183554,@ACT=NULL,@Sat_Type=NULL

Which shows first off that all the UpdateParameters came back NULL instead of the new values I typed in, then the rest of the values are the entirety of the columns in the GridView. obviously, when trying to execute the stored proecdure, it's throwing every column in the GridVew into the SP, and I understand why the error message now, I just have NO earthly idea how to fix it. HOW do I tell it only pass in those 5 values, and how do I make it actually take in the values from the Edit TextBoxes rather than NULL?
[+][-]04/14/08 08:08 AM, ID: 21350655Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, Visual Studio, SQL Server 2005
Tags: ASP.Net
Sign Up Now!
Solution Provided By: SeTech
Participating Experts: 1
Solution Grade: A
 
[+][-]03/14/08 09:16 AM, ID: 21126832Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/21/08 10:46 AM, ID: 21181674Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 / EE_QW_2_20070628