I'm having a problem. I have a stored procedure for selecting items like this:
And so on. See how it gives aliases for the data.
I bind it to a gridview like so:
But not so well for updating. My update stored procedure is like this:
Where am I going wrong? I get a "too many arguments specified" error, and I can look at the profiler and see that I'm passing in Name, ID, p_MILESTONENAME, p_MILESTONEID. Can't I rename the parameters in the datasource? Is there another way? The stored procedures should look like that with those parameter names, so I don't know what else I can do.
Thanks!
James
Code:
SELECT
intMilestoneID [ID],
strMilestoneName [Name],
strMilestoneDescription [Desc],
intMilestoneOrder [MSOrder],
And so on. See how it gives aliases for the data.
I bind it to a gridview like so:
Code:
<asp:GridView ID="grid_milestone"
DataSourceID="DSProject"
AutoGenerateColumns="false"
AutoGenerateEditButton="true" runat="server">
<Columns>
<asp:BoundField DataField="ID" />
<asp:BoundField DataField="Name" />
</Columns>
</asp:GridView>code]
My datasource works great for selecting:
[code<asp:SqlDataSource ID="DSProject" ConnectionString="<%$ AppSettings:SQLConnection1 %>"
SelectCommand="uspSELECT_MILESTONE"
SelectCommandType="StoredProcedure"
UpdateCommand="uspUPDATE_MILESTONE"
UpdateCommandType="StoredProcedure"
CancelSelectOnNullParameter="true"
runat="server">
<SelectParameters>
<asp:QueryStringParameter QueryStringField="project" Name="p_PROJECTID" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="p_MILESTONEID" />
<asp:Parameter Name="p_MILESTONENAME" />
</UpdateParameters>
</asp:SqlDataSource>
But not so well for updating. My update stored procedure is like this:
Code:
REATE PROCEDURE uspUPDATE_MILESTONE
-- Add the parameters for the stored procedure here
@p_MILESTONEID int = null,
@p_MILESTONENAME varchar(50) = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
UPDATE tblProjectMilestone
SET
strMilestoneName = @p_MILESTONENAME
WHERE
intMilestoneID = @p_MILESTONEID
END
Where am I going wrong? I get a "too many arguments specified" error, and I can look at the profiler and see that I'm passing in Name, ID, p_MILESTONENAME, p_MILESTONEID. Can't I rename the parameters in the datasource? Is there another way? The stored procedures should look like that with those parameter names, so I don't know what else I can do.
Thanks!
James