[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(0);
                        b.ModuleClass = read.GetString(1);
                        b.IMGradeRule = read.GetString(2);
                        b.LEVEL_COLOR = read.GetString(3);
                        b.Pmax = read.GetDouble(4);
                        b.StandP = read.GetString(5).TrimEnd('W');
                        b.Im = read.GetDouble(6);
                        b.CtlValue = read.GetString(7);
                        b.MinValue = read.GetString(8);
                        b.MaxValue = read.GetString(9);
                        b.SchemeName = read.GetString(10);
                        b.PmaxId = read.GetString(11);
                    }

原文地址:https://www.cnblogs.com/masonlu/p/9798080.html