Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
davidshq
Posting Yak Master
119 Posts |
Posted - 2005-11-23 : 22:44:50
|
Here is my page:<%@ Page Language="VB" MasterPageFile="~/Admin.master" AutoEventWireup="false" CodeFile="EditDetailGames.aspx.vb" Inherits="Admin_EditDetailGames" title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:databaseConnectionString %>" SelectCommand="SELECT * FROM [Game]" UpdateCommand="UPDATE Game SET [Title] = @Title, [Popularity] = @Popularity, [Description] = @Description, [Dangers] = @Dangers, [Variants] = @Variants, [Source] = @Source, [Type] = @Type, [Approved] = @Approved, WHERE [ID]=@ID"> <UpdateParameters> <asp:Parameter Name="ID" Type="Int32" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Popularity" Type="Int16" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Dangers" Type="String" /> <asp:Parameter Name="Variants" Type="String" /> <asp:Parameter Name="Source" Type="String" /> <asp:Parameter Name="Type" Type="String" /> <asp:Parameter Name="Approved" Type="Int16" /> </UpdateParameters> </asp:SqlDataSource> <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateInsertButton="True" AutoGenerateRows="False" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource1" DefaultMode="Edit" ForeColor="Black" GridLines="Vertical" Height="50px" Width="423px" DataKeyNames="ID"> <FooterStyle BackColor="#CCCC99" /> <EditRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F7DE" /> <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /> <Fields> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="True" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:BoundField DataField="Popularity" HeaderText="Popularity" SortExpression="Popularity" /> <asp:BoundField DataField="YourPopularity" HeaderText="YourPopularity" SortExpression="YourPopularity" /> <asp:TemplateField HeaderText="Description" SortExpression="Description"> <EditItemTemplate> <asp:Textbox ID="TextBox1" runat="server" TextMode="MultiLine" Text='<%# Bind("Description") %>'></asp:Textbox> </EditItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Dangers" HeaderText="Dangers" SortExpression="Dangers" /> <asp:BoundField DataField="Variants" HeaderText="Variants" SortExpression="Variants" /> <asp:BoundField DataField="Source" HeaderText="Source" SortExpression="Source" /> <asp:BoundField DataField="Last Played" HeaderText="Last Played" SortExpression="Last Played" /> <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" /> <asp:BoundField DataField="Approved" HeaderText="Approved" SortExpression="Approved" /> </Fields> <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:DetailsView> <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox></asp:Content>Here is my error:ncorrect syntax near 'nvarchar'.Incorrect syntax near the keyword 'WHERE'.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Incorrect syntax near the keyword 'WHERE'.Any ideas?David.- http://www.civilwarsearch.com/- http://www.thehungersite.com/- http://www.grid.org/ |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2005-11-23 : 22:54:00
|
in the UpdateCommand, remove the comma before WHERE@Source, [Type] = @Type, [Approved] = @Approved WHERE [ID]=@ID"> -----------------[KH] |
 |
|
davidshq
Posting Yak Master
119 Posts |
Posted - 2005-11-23 : 22:56:00
|
Thanks. But now I get: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@ID".Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@ID".- http://www.civilwarsearch.com/- http://www.thehungersite.com/- http://www.grid.org/ |
 |
|
33788
Starting Member
1 Post |
Posted - 2006-10-25 : 01:38:53
|
quote: Originally posted by davidshq Thanks. But now I get: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@ID".Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@ID".- http://www.civilwarsearch.com/- http://www.thehungersite.com/- http://www.grid.org/
Hi, I am very new to all this SQL and ASP.net stuff so please excuse my lack of terminology and explaination on some of these things. I am having the same problems as you were with getting the Must declare the scalar variable "@ID". I've been searching high and low and can't figure this out, pretty much dead in the water now. If you don't mind sharing how you was able to get the problem fix that would be very helpful. Any help you can provide will be much appreciated. Thanks ahead. |
 |
|
|
|
|
|
|