Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview updating/deleting with datasource

Status
Not open for further replies.

andy2325

Programmer
Jul 2, 2007
13
US
I seem to get errors saying thet my stored procedures have to many paramters. Anyone have any advice? Below is my code for the page and store procedures:
****************************************************

<%@ Register Src="Header.ascx" TagName="Header" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
<link href="" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
&nbsp;&nbsp;<br />
&nbsp;
<asp:TextBox ID="txtName" runat="server" Style="z-index: 101; left: 142px; position: absolute;
top: 73px" Enabled="False"></asp:TextBox>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;&nbsp;
<asp:Button ID="cmdContact" runat="server" Style="z-index: 102; left: 13px; position: absolute;
top: 572px" Text="Contact Customer Service" Width="156px" PostBackUrl="~/Contact.aspx" />
&nbsp;
<asp:Label ID="lblName" runat="server" Style="z-index: 103; left: 51px; position: absolute;
top: 74px" Text="Customer:" Width="85px"></asp:Label>
<uc1:Header ID="Header1" runat="server" />
&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
<asp:TextBox ID="txtJNumber" runat="server" Style="z-index: 104; left: 144px; position: absolute;
top: 75px" Visible="False"></asp:TextBox>

</div>
<asp:Label ID="lblOutput" runat="server" Style="z-index: 105; left: 53px; position: absolute;
top: 528px" Width="650px"></asp:Label>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
<asp:DataGrid ID="dgStatusNumber" runat="server" AllowCustomPaging="True" AllowPaging="True"
AllowSorting="True" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" Height="381px"
PageSize="5" Style="z-index: 106; left: 7px; position: absolute; top: 117px"
Width="348px">
<FooterStyle BackColor="#CCCCCC" />
<SelectedItemStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" Mode="NumericPages" />
<ItemStyle BackColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:ButtonColumn CommandName="Select" Text="Select"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
&nbsp; &nbsp;&nbsp;
<asp:SqlDataSource ID="dsStatus" runat="server" ConnectionString="<%$ ConnectionStrings:StatusConnectionString6 %>"
DeleteCommand="D_Status" DeleteCommandType="StoredProcedure" SelectCommand="Dsp_Customer" SelectCommandType="StoredProcedure"
UpdateCommand="U_Status" UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:parameter Name="JobNumber" Type="String" />
<asp:parameter Name="Status" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="JobNumber" Type="String" />
<asp:parameter Name="Status" Type="String" />
<asp:parameter Name="Date" Type="DateTime" />
<asp:parameter Name="JName" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="txtJNumber" Name="JobNumber" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="dgInfo" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
CellPadding="4" CellSpacing="2" DataKeyNames="JobNumber,StatusPending" DataSourceID="dsStatus"
ForeColor="Black" Height="345px" PageSize="4" Style="z-index: 107; left: 383px;
position: absolute; top: 118px" Width="482px">
<FooterStyle BackColor="#CCCCCC" />
<Columns>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
<asp:BoundField DataField="JobNumber" HeaderText="JobNumber" ReadOnly="True" SortExpression="JobNumber" />
<asp:BoundField DataField="StatusPending" HeaderText="StatusPending" ReadOnly="True" SortExpression="StatusPending" />
<asp:BoundField DataField="JobName" HeaderText="JobName" SortExpression="JobName" />
<asp:BoundField DataField="Dte" HeaderText="Date" SortExpression="Dte" />
</Columns>
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</form>
</body>
</html>
************************************************************
/*
Name: Update_Status
Author: Andrew
Description: Updates Status Information
*/
ALTER PROCEDURE dbo.U_Status

(
@JobNumber char(10),
@Status char(10),
@Date datetime,
@JName char(10)
)

AS
Update dtStatus

SET

Dte = @Date,
JobName = @JName

Where (JobNumber = @JobNumber) and (StatusPending = @Status)
RETURN
************************************************************
/*
Name: D_Status
Author: Andrew
Description: Deletes Job Information
*/
ALTER PROCEDURE dbo.D_Status

(
@JobNumber char(10),
@Status char(10)

)

AS
/* SET NOCOUNT ON */
Delete from dtStatus
where
(JobNumber = @JobNumber)AND(StatusPending = @Status)
RETURN
************************************************************
 
Perhaps the names of the parameters require the @ sign added to the front to match the stored procedures:

Code:
            <DeleteParameters>
                <asp:Parameter Name="@JobNumber" Type="String" />
                <asp:Parameter Name="@Status" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="@JobNumber" Type="String" />
                <asp:Parameter Name="@Status" Type="String" />
                <asp:Parameter Name="@Date" Type="DateTime" />
                <asp:Parameter Name="@JName" Type="String" />
            </UpdateParameters>

ADO.NET usually requires you to include the @ sign.


Bob Boffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top