Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

Help: What is wrong with this code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Progman - 19 Feb 2006 02:30 GMT
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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.