且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从GridView值更新

更新时间:2023-02-10 17:57:29

从您的解释中不清楚。但我可以在代码中看到一个问题。

Not clear from your explanation. But I can see one problem in the code.
cmd1.Parameters.AddWithValue("@UsrId", TextBox1.Text);



这意味着它需要一个参数 @UserId 在查询中,但您没有在下面的命令中提到该参数。


That means it expects one Parameter @UserId in the query, but you have not mentioned that parameter in the below Command.

SqlCommand cmd1 = new SqlCommand("update Usr_Dtl set UsrId=@UsrId,ScreenCode=@ScreenCode,ScreenName=@ScreenName,UsrAccess=@UsrAccess,Delflg=@Delflg where UsrId = '" + TextBox1.Text + "'", con);



因此,将命令更改为...


So, change the Command to...

SqlCommand cmd1 = new SqlCommand("update Usr_Dtl set UsrId=@UsrId,ScreenCode=@ScreenCode,ScreenName=@ScreenName,UsrAccess=@UsrAccess,Delflg=@Delflg where UsrId = @UsrId", con);





另外,我建议您调试并查看在替换Command中参数的所有值后,它所做的动态查询是什么。确保它是正确的。



Also, I would suggest you to debug and see what is the dynamic query it makes after replacing all values for the parameters in the Command. Make sure that is correct.


通过调试代码检查网格行索引并清楚地解释问题
Check your grid row index by debugging the code and clearly explain the problem