Conversion from string yyyyMMdd to integer is invalid

I have a dataset containing a datatable and I am listing all the rows in that datatable. When I try to format a column on that line, I throw an exception. (Part of) the code:

For Each dr As DataRow In ds.Tables("records").Rows
    file = dr("timestamp").ToString("yyyyMMdd") & "~.wav"
Next

      

As a result, you receive the following error message:

Conversion from string yyyyMMdd to Integer input is invalid. (translation from Dutch error message into English equivalent)

dr ("timestamp"). GetType.FullName results in "System.DateTime" so I don't understand why I am throwing this exception, for example Now.ToString ("yyyyMMdd") results in "20091002" and "Now" is the same type as dr ( "timestamp"), "System.DateTime".

+2


source to share


2 answers


Try



For Each dr As DataRow In ds.Tables("records").Rows
    file = CDate(dr("timestamp")).ToString("yyyyMMdd") & "~.wav"
Next

      

+12


source


Are you sure you are not declaring the variable "file" as an integer?



0


source







All Articles