处理数据集 [英] Manipulating Datasets

查看:55
本文介绍了处理数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,可从注册表中获取信息.此功能的列为"RegistrationDate".

我正在尝试获取数据集中的数据-在其中我只想检索列的日期部分.

I have a dataset which fetches the information from a Registration table. This able has a column "RegistrationDate".

I am trying to get the data in the dataset - in it I want to retrieve just the date part of the column.

for each drow as data.datarow in ds.tables("Registration").rows
 dim dt as datetime = ctype(drow.item("RegistrationDate"),datetime)
 drow.item("RegistrationDate") = dt.date
next


我知道有问题,因为当我再次读取数据集时,我没有得到更改后的值.


I know something is wrong, because when I read the dataset again, I do not get the changed value.

推荐答案

您是否尝试调试?

首先检查日期是否以字符串格式正确获取.
然后检查对日期时间的转换是否正确,以确保您没有浪费时间
最后,根据需要使用Dates toLongDateTimeString()属性.

Did you tried to debug?

First check if the date was fetched correctly in string format.
Then check if the casting to datetime was correct such that you didn''t loose the time
Lastly, use the Dates toLongDateTimeString() proerty if needed.

drow.item("RegistrationDate") = dt.date


在dt之后,按点并检查可用属性以获取日期字符串.此外,将字符串转换为日期时间后,您可以指定特定格式来显示日期时间.


Here after dt, press the dot and check for available properties to get date string. Further, once the string is casted to datetime, you can specify specific format to present the datetime.


<br />
 Dim dt As Data.DataTable = ds.Tables("Registration")<br />
        Dim lst As New List(Of DateTime)<br />
        For Each _row As Data.DataRow In dt.Rows<br />
            lst.Add(_row("RegistrationDate"))<br />
        Next<br />


hello,

我认为代码很好.如果日期格式不正确,则应引发异常.确保在操作之后该应用程序不会重新填充"Registration"表.
hello,

I think the code is fine. It should throw an exception if the date is not in correct format. Make sure the applciation does not re-populating the "Registration" table after the manipulation.


这篇关于处理数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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