Fehlermeldung: Für die Prozedur oder Funktion wurden zu viele Argumente angegeben.

duukta

Grünschnabel
Ich fang mal an, hoffe hier bin ich richtig. Hab eine GridView mit "Header-Informationen". Wenn ich nen Datensatz auswähle, hätte ich gern, dass dazu dann detaillierte Informationen zu diesem Datensatz angezeigt werden. Allerdings bekomme ich immer folgende Fehlermeldung:

Für die Prozedur oder Funktion proc_ShowTaskForCall wurden zu viele Argumente angegeben.

Die DB Prozedur bekommt einen Input Parameter (ID) und dazu sollen dann die entsprechenden Detaildatensätze ausgegeben werden.

Code:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2"  
                            CellPadding="4" ForeColor="#333333" GridLines="Horizontal" BorderStyle="Groove" BorderWidth="2" BorderColor="#59A60C"  
                            DataKeyNames="SupportCallID" ShowFooter="True" 
                            OnSelectedIndexChanged="GridView2_SelectedIndexChanged" AllowPaging="True" AutoGenerateSelectButton="true">
                         <RowStyle  ForeColor="Black" />
                         <HeaderStyle BackColor="#66B849" ForeColor="White" Font-Bold="True" />
                         <AlternatingRowStyle BackColor="gray" VerticalAlign="Middle" />                      
                         <Columns>
                              <asp:BoundField DataField="SupportCallID"  HeaderText="SupportCallID" SortExpression="SupportCallID" visible="false"/>
                              <asp:BoundField DataField="Brief_Description" HeaderText="Brief Description" SortExpression="Brief Description" />
                              <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                              <asp:BoundField DataField="COMPANYDID" HeaderText="Contact" SortExpression="Contact" />
                              <asp:BoundField DataField="COMPANYID" HeaderText="Company" SortExpression="Company" />
                              <asp:BoundField DataField="STATUSID" HeaderText="Status" SortExpression="Status" />
                              <asp:BoundField DataField="PRIORITYID" HeaderText="Priority" SortExpression="Priority" />
                              <asp:BoundField DataField="TYPEID" HeaderText="Type" SortExpression="Type" />
                              <asp:CommandField SelectText="Select" UpdateText="Update" CancelText="Cancel" ShowEditButton="True" EditText="Edit" />
                         </Columns>                                        
                 </asp:GridView>
                 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:scpmv3 %>"
                            SelectCommand="proc_OpenCalls" SelectCommandType="StoredProcedure"
                            UpdateCommand="update support_call
		                                    set BRIEF_DESCRIPTION = @Brief_Description, 
			                                Description = @Description, 
			                                COMPANYDID = @COMPANYDID, 
			                                COMPANYID = @COMPANYID
		                                    where SUPPORTCALLID = @supportcallid">
                         <UpdateParameters>
                              <asp:Parameter Name="SupportCallID" Direction="Output"/>
                         </UpdateParameters>
                 </asp:SqlDataSource>
                 <asp:Label ID="SUPPORTCALLID" runat="server" Text=""></asp:Label>
                 <asp:Label ID="SUPPORTCALLDID" runat="server" Text=""></asp:Label>
                 <asp:Label ID="ACTION" runat="server" Text=""></asp:Label>
                 <asp:Label ID="TASK_CREATED" runat="server" Text=""></asp:Label>
                 <asp:Label ID="DATE_NEXT_ACTION" runat="server" Text=""></asp:Label>
                 <asp:Label ID="CALLREMIND" runat="server" Text=""></asp:Label>
                 <asp:Label ID="MESSAGE" runat="server" Text=""></asp:Label>

Code:
SqlParameter SUPPORTCALLID_SQL;
    SqlParameter SUPPORTCALLDID_SQL;
    SqlParameter ACTION_SQL;
    SqlParameter TASK_CREATED_SQL;
    SqlParameter DATE_NEXT_ACTION_SQL;
    SqlParameter CALLREMIND_SQL;
    SqlParameter MESSAGE_SQL;


    protected void Page_Load(object sender, EventArgs e)
    {
        conString = "server=(local);" +
              "Trusted_Connection=yes; database=SCPMv3";
        con = new SqlConnection(conString);

    }
    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {
       
        int index = GridView2.SelectedIndex;
        String SUPPORTCALLID = GridView2.DataKeys[index].Value.ToString();
        getDetails(SUPPORTCALLID);
    }
    protected void getDetails(String SUPPORTCALLID)
    {
        con.Open();
        command = new SqlCommand("proc_ShowTaskForCall", con);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add(new SqlParameter("@SUPPORTCALLID", SqlDbType.VarChar)).Value = SUPPORTCALLID;


        //Output-Parameters for the Detailed-View

        SUPPORTCALLID_SQL = command.Parameters.Add("@SUPPORTCALLID", SqlDbType.Int);
        SUPPORTCALLID_SQL.Direction = ParameterDirection.Output;
        SUPPORTCALLID_SQL.Size = 100;

        SUPPORTCALLDID_SQL = command.Parameters.Add("@SUPPORTCALLDID", SqlDbType.Int);
        SUPPORTCALLDID_SQL.Direction = ParameterDirection.Output;
        SUPPORTCALLDID_SQL.Size = 100;

        ACTION_SQL = command.Parameters.Add("@ACTION", SqlDbType.VarChar);
        ACTION_SQL.Direction = ParameterDirection.Output;
        ACTION_SQL.Size = 100;

        TASK_CREATED_SQL = command.Parameters.Add("@TASK_CREATED", SqlDbType.DateTime);
        TASK_CREATED_SQL.Direction = ParameterDirection.Output;
        TASK_CREATED_SQL.Size = 100;

        DATE_NEXT_ACTION_SQL = command.Parameters.Add("@DATE_NEXT_ACTION", SqlDbType.DateTime);
        DATE_NEXT_ACTION_SQL.Direction = ParameterDirection.Output;
        DATE_NEXT_ACTION_SQL.Size = 100;

        CALLREMIND_SQL = command.Parameters.Add("@CALLREMIND", SqlDbType.VarChar);
        CALLREMIND_SQL.Direction = ParameterDirection.Output;
        CALLREMIND_SQL.Size = 1;

        MESSAGE_SQL = command.Parameters.Add("@MESSAGE", SqlDbType.VarChar);
        MESSAGE_SQL.Direction = ParameterDirection.Output;
        MESSAGE_SQL.Size = 200;

        command.ExecuteNonQuery();
        con.Close();

Hier sind mal die Codeausschnitte. Hab ich hier nen grundsätzlichen Denkfehler oder ist mein Lösungsansatz so ok? Wenn ja, wo kann der Fehler genau sein? Bin immer noch in der Anfangs- und Probierphase, nutze deshalb immer Codeausschnitte anderer und versuche mir daraus "meins" zu basteln :D

Evtl. weiss ja jemand von euch auf Anhieb, wo ich nen Fehler gemacht habe. Aber bitte nicht gleich steinigen ;)
Danke.
Gruss
 
Hi,
Manchmal sieht man vor lauter Bäumen den Wald nicht mehr. ^^

Mein Fehler war, dass ich davon ausgegangen bin, dass das Ergebnis der Prozedur "einfach so" an meine Oberfläche weiter gegeben wird. Doch muss ich die Werte nicht nur in der Select Anweisung definieren, sondern selber auch nochmal als Output Parameter. Eigentlich sehr simple ;-)

Gruss
 
Zurück