有没有办法读取float类型 [英] Is there a way to read type float

查看:131
本文介绍了有没有办法读取float类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用填充读取器从数据库中读取数据,并且不希望显示float类型的值.我尝试逐步执行代码,但是当到达类型float时,应用程序停止了,请帮助

Hi, Im reading data from the database using populate reader and the values that are type float don''t want to display. i tried going through the code step by step but when it reaches type float the application stops, please help

private void populate_report(Bank e, IDataReader dr)
{
   e.bank_id = dr.GetInt32(0);
   e.bankind_date = dr.GetString(1);
   e.r200 = dr.GetFloat(2);
   e.r100 = dr.GetFloat(3);
}

推荐答案

尝试一下,
Try this,
private void populate_report(Bank e, IDataReader dr)
{
   e.bank_id = dr.GetInt32(0);
   e.bankind_date = dr.GetString(1);

   if(! dr.IsDBNull(dr.GetDouble(2))
   {
     e.r200 = dr.GetDouble(2);
   }

   if(! dr.IsDBNull(dr.GetDouble(3))
   {
     e.r100 = dr.GetDouble(3);
   }
}


这篇关于有没有办法读取float类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆