如何在C#页面中从数据库中返回日期 [英] How Can I Retrive Date From Database In C# Page

查看:82
本文介绍了如何在C#页面中从数据库中返回日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在研究metroframework。在visual studio 2010 C#中,windows页面创建metro页面并使用metro DateTime。我使用插入数据。地铁网格中的显示和显示数据。



现在我点击metrogrid的数据,所有数据都会获得但是日期生成错误。



注意错误名称是 -

hello,
I am working on metroframework. in visual studio 2010 C# , windows page create metro page and use metro DateTime . i use insert data . and dispay data in metro grid.

now i click on metrogrid's data , all data get but date generate error.

note error name is-

The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.





我要追溯的数据库记录。但错误仅在metrodatetime上生成。

请解决此错误。



the record from database i want to retrive. but error generate only on metrodatetime .
pls solve this error.

推荐答案

我们不能。

我们无法访问您的数据,所以我们可以查看它并查看错误。

但是......大多数问题都是因为早期的设计决策不好project - 将日期或日期/时间值存储在字符串中。检查您的数据库,以及您在相关列中的确切内容。如果列是基于字符串的,那么您需要更改它并使用DATE或DATETIME列 - 并编写一个快速应用程序来转换值,记录失败。



问题在于,当您使用基于字符串的列时,所存储的值不可避免地在所有系统上都无法识别为有效日期:要么是因为它们是在没有正确检查的情况下输入的,要么是因为它们是在不同的区域设置或文化中输入的。当发生这种情况时,它会一直存在为隐藏问题,直到您尝试使用现在的实际数据为止。
We can't.
We don't have access to your data, so we can;t look at it and see what is wrong.
But...mostly problems like this are because of a bad design decision early in the project - storing Date or Date/Time values in strings. Check your DB, and exactly what you have in the relevant column. If the column is string based, then you need to change that and use a DATE or DATETIME column - and write a quick app to convert the values, logging the failures.

The trouble is that when you use string based columns, inevitably the values that get stored aren't recognisable as valid dates on all systems: either because they were entered without proper checking, or because they were entered in a different Locale, or Culture. When this happens, it persists as a "hidden" problem until you try to use the actual data as you are doing now.


这篇关于如何在C#页面中从数据库中返回日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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