SqlDbType.Decimal问题
public SettledParamInfo GetSettledParam(int CntOfValue)
{
SqlCommand sqlCmd = new SqlCommand();
SettledParamInfo sp = new SettledParamInfo();
AddParamToSQLCmd(sqlCmd, "@CountOfValue", SqlDbType.Int, 4, ParameterDirection.Input, CntOfValue);
SqlParameter outputA2 = sqlCmd.Parameters.Add("@A2", SqlDbType.Float); //如果写成SqlDbType.Decimal ,则返回的是整数,不是小数
outputA2.Direction = ParameterDirection.Output;
SqlParameter outputA3 = sqlCmd.Parameters.Add("@A3", SqlDbType.Float);
outputA3.Direction = ParameterDirection.Output;
SqlParameter outputB3 = sqlCmd.Parameters.Add("@B3", SqlDbType.Float);
outputB3.Direction = ParameterDirection.Output;
SqlParameter outputB4 = sqlCmd.Parameters.Add("@B4", SqlDbType.Float);
outputB4.Direction = ParameterDirection.Output;
SqlParameter outputD2 = sqlCmd.Parameters.Add("@D2", SqlDbType.Float);
outputD2.Direction = ParameterDirection.Output;
SqlParameter outputD3 = sqlCmd.Parameters.Add("@D3", SqlDbType.Float);
outputD3.Direction = ParameterDirection.Output;
SqlParameter outputD4 = sqlCmd.Parameters.Add("@D4", SqlDbType.Float);
outputD4.Direction = ParameterDirection.Output;
SqlParameter outputE2 = sqlCmd.Parameters.Add("@E2", SqlDbType.Float);
outputE2.Direction = ParameterDirection.Output;
sdba.ExecSPCommand("sp_Capability_GetSettledParam", sqlCmd);
sp.A2 = Convert.ToDecimal(outputA2.Value);//在这个地方再进行转换. 可见sqldbtype中的decimal和C#中的decimal意义不同
sp.A3 = Convert.ToDecimal(outputA3.Value);
sp.B3 = Convert.ToDecimal(outputB3.Value);
sp.B4 = Convert.ToDecimal(outputB4.Value);
sp.D2 = Convert.ToDecimal(outputD2.Value);
sp.D3 = Convert.ToDecimal(outputD3.Value);
sp.D4 = Convert.ToDecimal(outputD4.Value);
sp.E2 = Convert.ToDecimal(outputE2.Value);
return sp;
}
posted on 2008-02-01 10:38 TerryDing 阅读(11002) 评论(3) 编辑 收藏 举报