处理sqlcommand里面的参数时间:2022-10-22 13:11:31 忙了一个晚上终于搞定啦,要吐啦。 好不容易找到啦 下面是源代码。 需要设置参数的时候用“@”设置好变量,然后进行解决就可以啦。 name2 = name2.Trim(); decimal smoney = money1 - money2; // smoney = 10; SqlCommand mycomm3 = new SqlCommand( " update userinfo set account=@employeeid where name=' " + name2 + " ' " , Conn); SqlParameter sp1 = mycomm3.Parameters.Add( " @employeeid " , smoney); sp1.SourceColumn = " account " ; // 设置要更新的列 sp1.SourceVersion = DataRowVersion.Original; // 设置要更新的值的版本