I am getting the error:
"[Microsoft][SQL Native Client][SQL Server]Must declare the scalar variable
"@UserComment".]"
The code:
<asp:FormView ID="FormView1" runat="server" BackColor="White"
BorderColor="White" DefaultMode="Insert"
BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
DataSourceID="SqlDataSource1">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<EditRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<InsertItemTemplate>
UserComment:
<asp:TextBox ID="UserCommentTextBox" runat="server" Text='<%#
Bind("UserComment") %>'></asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert"
Text="Insert"></asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
UserComment:
<asp:Label ID="UserCommentLabel" runat="server" Text='<%#
Bind("UserComment") %>'></asp:Label><br />
</ItemTemplate>
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:VoteHelperConnectionString %>"
ProviderName="<%$ ConnectionStrings:VoteHelperConnectionString.ProviderName
%>"
DeleteCommand="DELETE FROM VoteHelper.dbo.VH_Data_GuestBook"
InsertCommand="INSERT INTO VoteHelper.dbo.VH_Data_GuestBook(UserComment)
VALUES (@UserComment)"
SelectCommand="SELECT [UserComment] FROM [VH_Data_GuestBook]"
UpdateCommand="UPDATE VoteHelper.dbo.VH_Data_GuestBook SET UserComment =
@UserComment">
<InsertParameters>
<asp:formparameter name="UserComment" formfield="UserCommentTextBox" />
</InsertParameters>
</asp:SqlDataSource>
Chris R. Timmons - 19 Feb 2006 03:25 GMT
Progman,
You're missing a section in <asp:SqlDataSource>. For the update
statement, an <UpdateParameters> section is needed just like you have
for <InsertParameters>:
<UpdateParameters>
<asp:formparameter name="UserComment"
formfield="UserCommentTextBox" />
</UpdateParameters>

Signature
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/