[C#]GetFloat提示"指定的转换无效"

数据库中没有double型,float就表示double值。
sql server数据库字段类型与.net的数据类型的对应关系:

real(数据库)<--> float(.NET)
float(数据库)<--> double(.NET)

读取数据库中的float类型的字段要使用GetDouble方法
读取数据库中的real类型的字段时才应该使用GetFloat方法

                    while (read.Read())
{
b.SN = read.GetString();
b.ModuleClass = read.GetString();
b.IMGradeRule = read.GetString();
b.LEVEL_COLOR = read.GetString();
b.Pmax = read.GetDouble();
b.StandP = read.GetString().TrimEnd('W');
b.Im = read.GetDouble();
b.CtlValue = read.GetString();
b.MinValue = read.GetString();
b.MaxValue = read.GetString();
b.SchemeName = read.GetString();
b.PmaxId = read.GetString();
}

[C#]GetFloat提示"指定的转换无效"

上一篇:计算机组成与设计 复习


下一篇:xxx was built without full bitcode" 编译错误解决