为什么SQL浮点数不同于C#float [英] Why is a SQL float different from a C# float
本文介绍了为什么SQL浮点数不同于C#float的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DataRow exercise = _exerciseDataSet。 Exercise.FindByExerciseID(65);
_AccelLimit =(float)exercise [DefaultAccelLimit];
现在,玩弄这个我确实使它工作,但没有任何意义,它没有感觉不对
_AccelLimit =(float)(double)exercise [DefaultAccelLimit];
任何人都可以解释我在这里缺少什么?
解决方案
根据 SQLDbType的文档。
Howdy, I have a DataRow pulled out of a DataTable from a DataSet. I am accessing a column that is defined in SQL as a float datatype. I am trying to assign that value to a local variable (c# float datatype) but am getting an InvalidCastExecption
DataRow exercise = _exerciseDataSet.Exercise.FindByExerciseID(65);
_AccelLimit = (float)exercise["DefaultAccelLimit"];
Now, playing around with this I did make it work but it did not make any sense and it didn't feel right.
_AccelLimit = (float)(double)exercise["DefaultAccelLimit"];
Can anyone explain what I am missing here?
解决方案
A SQL float is a double according to the documentation for SQLDbType.
这篇关于为什么SQL浮点数不同于C#float的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文