<div>My code:</div> <div><div>
<div></div> <div></div> <div><asp:DetailsViewID="DetailsView1"runat="server"Height="280px"Width="939px"</div> <div></div>
<div></div> <div>AutoGenerateDeleteButton="True"AutoGenerateEditButton="True"</div> <div></div>
<div></div> <div>AutoGenerateInsertButton="True"DataSourceID="SqlDataSource1"</div> <div></div>
<div></div> <div>AllowPaging="True"EnableModelValidation="True"Enabled="False"></div>
<div></div> <div></div> <div></asp:DetailsView></div>
<div></div> <div></div> <div><asp:TextBoxID="TextBoxCommand"runat="server"Enabled="False"Width="967px"OnTextChanged="TextBoxCommand_OnTextChanged"AutoPostBack="True"></asp:TextBox></div>
<div></div> <div></div> <div><asp:SqlDataSourceID="SqlDataSource1"runat="server"OnDeleting="OD"</div>
<div></div> <div></div> <div>ConnectionString="<%$
ConnectionStrings:muj%>"</div>
<div></div> <div></div> <div>InsertCommand="insert
into computer_talk values(@id,@str,@p1,@p2,@p3,@room)"</div> <div></div>
<div></div> <div>DeleteCommand="delete
from computer_talk where id=@id"</div>
<div></div> <div></div> <div>SelectCommand="select
id,str,p1,p2,p3,room from computer_talk"</div>
<div></div> <div></div> <div>UpdateCommand="update
computer_talk set id=@id,str=@str,p1=@p1,p2=@p2,p3=@p3,room=@room where id=@id"CancelSelectOnNullParameter="False"></div>
<div></div> <div></div> <div></asp:SqlDataSource></div>
</div> My problem: Update, select and insert command works without problems, but delete commnad generate error: System.Data.SqlClient.SqlException: Must declare the scalar variable "@id". I cannot understand why. I have more SqlDataSources connect to
GridView1, so I cannot define template or columns. Thanks for answer. mm</div> <div></div>
www.textovka...
Member
1 Points
1 Post
Must declare the scalar variable "@id"
Apr 10, 2011 06:29 AM|LINK
kedarrkulkar...
All-Star
34421 Points
5534 Posts
Re: Must declare the scalar variable "@id"
Apr 10, 2011 07:09 AM|LINK
try to set datakeynames property of gridview to id like this
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site