Hi all, I am using Visual Studio 2005, I have created a web application that uses a Grid View with a Delete, Update, insert commmand field. But I am getting the following error when I try to delete a record:
Must declare the variable '@FAQ1ID'.
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: Must declare the variable '@FAQ1ID'.
This is my code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Edit1.ascx.cs" Inherits="CMSWebParts_MyWebParts_Edit1" %>
<asp:GridView ID="GridView1" runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
AutoGenerateSelectButton="True" DataSourceID="SqlDataSource1" DataKeyNames="FAQ1ID">
<Columns>
<asp:BoundField DataField="FAQ1ID" HeaderText="FAQ1ID" InsertVisible="False" ReadOnly="True"
SortExpression="FAQ1ID" />
<asp:BoundField DataField="FormInserted" HeaderText="FormInserted" SortExpression="FormInserted" />
<asp:BoundField DataField="Area" HeaderText="Area" SortExpression="Area" />
<asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
<asp:BoundField DataField="Issue" HeaderText="Issue" SortExpression="Issue" />
<asp:BoundField DataField="Update" HeaderText="Update" SortExpression="Update" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="OverwriteChanges"
ConnectionString="<%$ ConnectionStrings
SCEMEAWEB_BConnectionString4 %>"
DeleteCommand="DELETE FROM [TBL_FAQ1] WHERE [FAQ1ID] = @FAQ1ID AND [FormInserted] = @original_FormInserted AND [Area] = @original_Area AND [Topic] = @original_Topic AND [Issue] = @original_Issue AND [Update] = @original_Update"
InsertCommand="INSERT INTO [TBL_FAQ1] ([FormInserted], [Area], [Topic], [Issue], [Update]) VALUES (@FormInserted, @Area, @Topic, @Issue, @Update)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [FAQ1ID], [FormInserted], [Area], [Topic], [Issue], [Update] FROM [TBL_FAQ1] WHERE ([Area] = @Area)"
UpdateCommand="UPDATE [TBL_FAQ1] SET [FormInserted] = @FormInserted, [Area] = @Area, [Topic] = @Topic, [Issue] = @Issue, [Update] = @Update WHERE [FAQ1ID] = @original_FAQ1ID AND [FormInserted] = @original_FormInserted AND [Area] = @original_Area AND [Topic] = @original_Topic AND [Issue] = @original_Issue AND [Update] = @original_Update">
<SelectParameters>
<asp
arameter DefaultValue="CXP" Name="Area" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp
arameter Name="original_FAQ1ID" Type="Int32" />
<asp
arameter Name="original_FormInserted" Type="DateTime" />
<asp
arameter Name="original_Area" Type="String" />
<asp
arameter Name="original_Topic" Type="String" />
<asp
arameter Name="original_Issue" Type="String" />
<asp
arameter Name="original_Update" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp
arameter Name="FormInserted" Type="DateTime" />
<asp
arameter Name="Area" Type="String" />
<asp
arameter Name="Topic" Type="String" />
<asp
arameter Name="Issue" Type="String" />
<asp
arameter Name="Update" Type="String" />
<asp
arameter Name="original_FAQ1ID" Type="Int32" />
<asp
arameter Name="original_FormInserted" Type="DateTime" />
<asp
arameter Name="original_Area" Type="String" />
<asp
arameter Name="original_Topic" Type="String" />
<asp
arameter Name="original_Issue" Type="String" />
<asp
arameter Name="original_Update" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp
arameter Name="FormInserted" Type="DateTime" />
<asp
arameter Name="Area" Type="String" />
<asp
arameter Name="Topic" Type="String" />
<asp
arameter Name="Issue" Type="String" />
<asp
arameter Name="Update" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
Thanks in advance!
Must declare the variable '@FAQ1ID'.
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: Must declare the variable '@FAQ1ID'.
This is my code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Edit1.ascx.cs" Inherits="CMSWebParts_MyWebParts_Edit1" %>
<asp:GridView ID="GridView1" runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
AutoGenerateSelectButton="True" DataSourceID="SqlDataSource1" DataKeyNames="FAQ1ID">
<Columns>
<asp:BoundField DataField="FAQ1ID" HeaderText="FAQ1ID" InsertVisible="False" ReadOnly="True"
SortExpression="FAQ1ID" />
<asp:BoundField DataField="FormInserted" HeaderText="FormInserted" SortExpression="FormInserted" />
<asp:BoundField DataField="Area" HeaderText="Area" SortExpression="Area" />
<asp:BoundField DataField="Topic" HeaderText="Topic" SortExpression="Topic" />
<asp:BoundField DataField="Issue" HeaderText="Issue" SortExpression="Issue" />
<asp:BoundField DataField="Update" HeaderText="Update" SortExpression="Update" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="OverwriteChanges"
ConnectionString="<%$ ConnectionStrings
DeleteCommand="DELETE FROM [TBL_FAQ1] WHERE [FAQ1ID] = @FAQ1ID AND [FormInserted] = @original_FormInserted AND [Area] = @original_Area AND [Topic] = @original_Topic AND [Issue] = @original_Issue AND [Update] = @original_Update"
InsertCommand="INSERT INTO [TBL_FAQ1] ([FormInserted], [Area], [Topic], [Issue], [Update]) VALUES (@FormInserted, @Area, @Topic, @Issue, @Update)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [FAQ1ID], [FormInserted], [Area], [Topic], [Issue], [Update] FROM [TBL_FAQ1] WHERE ([Area] = @Area)"
UpdateCommand="UPDATE [TBL_FAQ1] SET [FormInserted] = @FormInserted, [Area] = @Area, [Topic] = @Topic, [Issue] = @Issue, [Update] = @Update WHERE [FAQ1ID] = @original_FAQ1ID AND [FormInserted] = @original_FormInserted AND [Area] = @original_Area AND [Topic] = @original_Topic AND [Issue] = @original_Issue AND [Update] = @original_Update">
<SelectParameters>
<asp
</SelectParameters>
<DeleteParameters>
<asp
<asp
<asp
<asp
<asp
<asp
</DeleteParameters>
<UpdateParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
</UpdateParameters>
<InsertParameters>
<asp
<asp
<asp
<asp
<asp
</InsertParameters>
</asp:SqlDataSource>
Thanks in advance!