在c#win中显示datagridview中的数据时出现问题。形成 [英] Problem showing data in datagridview in c# win. form

查看:106
本文介绍了在c#win中显示datagridview中的数据时出现问题。形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一些数据( ACCESS ),如下所示: -

i have some data in database (ACCESS) which looks like this:-

Id  SName
1   GLE1/001
2   01
3   498
4   HYEP/0089



现在,当我从此查询中检索数据到数据表时

从项目中选择ID,格式(SName)。

它给了我以下记录: -


now, when i retrieve the data to datatable from this query
"Select Id,Format(SName) from Item".
It gives me the following record:-

Id  SName
1   GLE1/001
2   1          //here "01" got converted to "1"
3   498
4   HYEP/0089



名称字段的数据类型是备注或长文本

为什么将01转换为1?

推荐答案

因为您正在使用FORMAT功能:



Microsoft访问格式函数采用数字表达式并将其作为格式化字符串返回。

http://www.techonthenet.com/access/functions/numeric/format.php [ ^ ]



所以在为了传递一个数字值,将字符串01转换为数字 - 1 - 然后将FORMATED转换为字符串...



参加FORMAT out,它应该做你想要的。
Because you are using the FORMAT function:

"The Microsoft Access Format function takes a numeric expression and returns it as a formatted string."
http://www.techonthenet.com/access/functions/numeric/format.php[^]

So in order to pass it a numeric value, the string "01" is converted to a number - 1 - and then FORMATED back to a string...

Take the FORMAT out and it should do what you want.


这篇关于在c#win中显示datagridview中的数据时出现问题。形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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