hello
i am using a detailsview to update. i am using a stored procedure. but every time i try to update it gives exception "Procedure or function has too many arguments specified". i have tried using formview and gridview also but the exception is same. below is my code. primary key in the table is Company_ID. DataKeyNames is also set to primary key.
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Company_ID"
DataSourceID="SqlDataSource1" DefaultMode="Edit" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Company_ID" HeaderText="Company_ID" InsertVisible="False"
ReadOnly="True" SortExpression="Company_ID" />
<asp:BoundField DataField="Cmp_Name" HeaderText="Cmp_Name" SortExpression="Cmp_Name" />
<asp:BoundField DataField="Cmp_Address" HeaderText="Cmp_Address" SortExpression="Cmp_Address" />
<asp:BoundField DataField="Country_ID" HeaderText="Country_ID" SortExpression="Country_ID" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Web_Address" HeaderText="Web_Address" SortExpression="Web_Address" />
<asp:BoundField DataField="Ph_No" HeaderText="Ph_No" SortExpression="Ph_No" />
<asp:BoundField DataField="Contact_Person" HeaderText="Contact_Person" SortExpression="Contact_Person" />
<asp:BoundField DataField="CP_Phone" HeaderText="CP_Phone" SortExpression="CP_Phone" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JSGConnectionString %>"
SelectCommand="selectCompanyLessLogo" SelectCommandType="StoredProcedure" UpdateCommand="updateCompanyLessLogo"
UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="cmpName" Type="String" />
<asp:Parameter Name="address" Type="String" />
<asp:Parameter Name="country" Type="Int32" />
<asp:Parameter Name="desc" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="phone" Type="String" />
<asp:Parameter Name="contactperson" Type="String" />
<asp:Parameter Name="contactphone" Type="String" />
<asp:Parameter Name="city" Type="String" />
<asp:Parameter Name="Company_ID" Type="Int64" />
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter Name="Company_ID" SessionField="Company_ID" Type="Int64" />
</SelectParameters>
</asp:SqlDataSource>
my stored procedure is
set ANSI_NULLS ONset QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[updateCompanyLessLogo]
(
@cmpName nvarchar(100),
@address nvarchar(200),
@country int,
@desc nvarchar(4000),
@url nvarchar(50),
@phone nvarchar(20),
@contactperson nvarchar(100),
@contactphone nvarchar(20),
@city nvarchar(50),
@Company_ID bigint
)
AS
SET NOCOUNT OFF;
UPDATE Company
SET Cmp_Name = @cmpName, Cmp_Address = @address, Country_ID = @country, Description = @desc, Web_Address = @url, Ph_No = @phone, Contact_Person = @contactperson, CP_Phone = @contactphone, City = @city
WHERE (Company_ID = @Company_ID)
below is my stack trace, may be it can help
Exception Details: System.Data.SqlClient.SqlException: Procedure or function updateCompanyLessLogo has too many arguments specified
[SqlException (0x80131904): Procedure or function updateCompanyLessLogo has too many arguments specified.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857194
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734806
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +401
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +721
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +1152
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +461
System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
thanks in advance
Regards
Please Remember to click "Mark as Answer" on this post if it helped you.
Ch. Zeeshan Nasir