开发者

unable to delete a record in Data grid view

error is coming while i'm tryin to delete a record from data source grid view. error message is giving ."Must declare the scalar variable "@regid"." my delete query "DELE开发者_运维知识库TE from tablename where reg_id=@regid"

plz give me some solution

thanks Churchill


Did you add the paramater to Delete Command??

Add like this:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="reg_id" CellPadding="4"
DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Style="z-index: 100;
left: 0px; position: absolute; top: 0px">
<DeleteParameters>
<asp:Parameter Name="@regid" Type="int32" />
</DeleteParameters>
</asp:GridView>


If your query is in stored procedure you must declare a variable to pass the value

i.e.

CREATE PROCEDURE usp_Delete
   @regid INT
AS

DELETE from tablename where reg_id=@regid

But if your query is hard-coded to the application you can concatinate the variable to the query like this

String sql = "DELETE from tablename where reg_id=" + regid.Text
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜