ASP.NET 2.0, Dataview and Stored Procedure

K

Kevin Buchanan

Following are the stored procedure and HTML.

This is a simple example - I am trying to use the stored procedure to update
the data in the dataview. It gives the following error:

"Function or stored procedure has too many arguements."

How do I use a SP to update data with the "new ASP.NET 2.0" control?

Thanks!!!


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_UpdateItemDesc]
(
@parmItemId numeric,
@parmItemDesc nvarchar(50)
)
AS
SET NOCOUNT ON
Update ItemDesc
set ItemDesc = @parmItemDesc
where ID = @parmItemID;
SET NOCOUNT OFF




<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body bottommargin="0" topmargin="0">
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow"
BorderColor="Tan"
BorderWidth="1px" CellPadding="2" DataKeyNames="ID"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
ForeColor="Black" GridLines="None">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:CommandField ShowEditButton="true" ButtonType="Button" />
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="ItemDesc" HeaderText="ItemDesc"
SortExpression="ItemDesc" />
</Columns>
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue"
ForeColor="GhostWhite" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Website1ConnectionString1 %>"
DeleteCommand="DELETE FROM [ItemDesc] WHERE [ID] = @original_ID"
InsertCommand="INSERT INTO [ItemDesc] ([ItemDesc]) VALUES (@ItemDesc)"
SelectCommand="SELECT [ID], [ItemDesc] FROM [ItemDesc]"
UpdateCommand="sp_UpdateItemDesc" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:parameter Name="original_ID" Type="Decimal" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter DefaultValue="" Name="parmItemId"
Type="Decimal" />
<asp:parameter DefaultValue="" Name="parmItemDesc"
Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="ItemDesc" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top