为什么一个SQL浮动从C#浮不同 [英] Why is a SQL float different from a C# float
本文介绍了为什么一个SQL浮动从C#浮不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我有一个DataRow掏出一个DataTable从一个数据集。我访问了在SQL定义为float数据类型的列。我想这个值赋给一个局部变量(C#浮点数据类型),但我得到一个InvalidCastExecption
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?
推荐答案
一个SQL浮动是双重根据的为的SqlDbType 的文档。
A SQL float is a double according to the documentation for SQLDbType.
这篇关于为什么一个SQL浮动从C#浮不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文