在写一个计算贷款利息的语句时发现的。strsql="UPDATE plus_bank SET savemoney=savemoney(1+@lixi)-@qukuan,savedate=@savedate where userid=" + userid;
这句在ExecuteNonQuery时出错,报找不到函数savemoney,而下面的则可以,觉得有点奇怪,难道SQL语句还有这种局限性。
strsql="UPDATE plus_bank SET savemoney=savemoney+savemoney*@lixi-@qukuan,savedate=@savedate where userid=" + userid;
SqlCommand cmd3 = new SqlCommand(strsql,myConn);
cmd3.Parameters.Add("@lixi",SqlDbType.Float,4).Value = rate*(DateTime.Now.Year-mysavedate.Year+(DateTime.Now.Month-mysavedate.Month));
cmd3.Parameters.Add("@qukuan",SqlDbType.Int,4).Value = myqukuan;
cmd3.Parameters.Add("@savedate",SqlDbType.DateTime,4).Value = DateTime.Now;
try
{
dr.Close();
cmd3.ExecuteNonQuery();
}
catch(Exception Ex)
{
Response.Write("Q异常捕获!"+Ex);
Response.End();
}
这句在ExecuteNonQuery时出错,报找不到函数savemoney,而下面的则可以,觉得有点奇怪,难道SQL语句还有这种局限性。
strsql="UPDATE plus_bank SET savemoney=savemoney+savemoney*@lixi-@qukuan,savedate=@savedate where userid=" + userid;
SqlCommand cmd3 = new SqlCommand(strsql,myConn);
cmd3.Parameters.Add("@lixi",SqlDbType.Float,4).Value = rate*(DateTime.Now.Year-mysavedate.Year+(DateTime.Now.Month-mysavedate.Month));
cmd3.Parameters.Add("@qukuan",SqlDbType.Int,4).Value = myqukuan;
cmd3.Parameters.Add("@savedate",SqlDbType.DateTime,4).Value = DateTime.Now;
try
{
dr.Close();
cmd3.ExecuteNonQuery();
}
catch(Exception Ex)
{
Response.Write("Q异常捕获!"+Ex);
Response.End();
}