问题描述
我有一个包含数据表的数据集,我枚举该数据表中的所有行。当尝试格式化该行中的列时,我遇到异常。 (部分)代码是: 对于每个dr作为DataRow在ds.Tables(记录)。Rows
file = dr(timestamp)。ToString(yyyyMMdd)& 〜.wav
下一个
这将导致以下错误消息:
从字符串yyyyMMdd转换为类型整数是无效的。
(从荷兰语错误消息转换为英文等价物)
dr(timestamp)GetType.FullName导致System.DateTime,所以我不明白为什么我遇到这个异常,例如 Now。 ToString(yyyyMMdd)导致20091002,Now与dr(timestamp),System.DateTime的类型相同。
尝试
对于每个dr As DataRow在ds.Tables (records)。Rows
file = CDate(dr(timestamp))ToString(yyyyMMdd)& 〜.wav
下一个
I have a dataset containing a datatable, and I enumerate all rows in that datatable. When trying to format a column in that row, I run into an exception. (Part of) the code is:
For Each dr As DataRow In ds.Tables("records").Rows
file = dr("timestamp").ToString("yyyyMMdd") & "~.wav"
Next
This results in the following error message:
Conversion from string yyyyMMdd to type Integer is not valid.(translated from a Dutch error message to the English equivalent)
dr("timestamp").GetType.FullName results in "System.DateTime", so I don't understand why I run into this exception, as for example Now.ToString("yyyyMMdd") results in "20091002", and "Now" is of the same type as dr("timestamp"), "System.DateTime" that is.
Try
For Each dr As DataRow In ds.Tables("records").Rows
file = CDate(dr("timestamp")).ToString("yyyyMMdd") & "~.wav"
Next
这篇关于从字符串yyyyMMdd转换为整型是无效的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!