本文介绍了错误,我声明了标量变量totalamt,平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新tbl_OpdClaim设置totalamt = {@ totalamt),Balance =(@ Balance)其中userid =''" + txtUserId.Text +''";


我收到此错误错误:''必须声明标量变量我没有得到什么错误的PLZ帮助我

update tbl_OpdClaim set totalamt=(@totalamt ),Balance =(@Balance ) where userid=''" + txtUserId.Text + "''";


i got this error Error: ''Must declare the scalar variable i am not getting what''s wrong plz help me

推荐答案

SqlCommand com = new SqlCommand("UPDATE tbl_OpdClaim SET totalamt=(@totalamt ),Balance =(@Balance ) WHERE userid=@ID", con);
com.Paramaters.AddWithValue("@totalamt", myTotalAmount);
com.Paramaters.AddWithValue("@Balance", myNewBalance);
com.Paramaters.AddWithValue("@ID", txtUserId.Text);



还要注意,您应该参数化ID:串联这样的字符串是对意外或故意的SQL注入攻击的邀请.



Note also that you should parameterize you ID: concatenating strings like that is an invitation to an accidental or deliberate SQL Injection attack.


SqlCommand cmd = new SqlCommand("update tbl_OpdClaim set totalamt=(@totalamt ),Balance =(@Balance ) where userid='" + txtUserId.Text + "'", con);
        cmd.Parameters.AddWithValue("@totalamt", amountvalue);
        cmd.Parameters.AddWithValue("@Balance", balance);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();


这篇关于错误,我声明了标量变量totalamt,平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 14:57