Link to home
Start Free TrialLog in
Avatar of rmartes
rmartes

asked on

VB.Net Timespan to String

Hi Experts,

I'm trying to display data from a MySqlDataReader. One of the returned values is a timespan in the following format (00:00:00). However, I keep getting the following error:

Conversion from type 'TimeSpan' to type 'String' is not valid.

I googled and found some articles, but still getting error.

Here is what I have so far:
Dim ts As TimeSpan
Dim dnd As String
If (Not dbReader.IsDBNull(dbReader.GetOrdinal("time_in_do_not_disturb"))) Then
   ts = TimeSpan.Parse(dbReader("time_in_do_not_disturb")) 'this line doesn't work
   dnd = String.Format("{hh\\:mm\\:ss}", ts)
Else
End If

Open in new window


How can I convert the above timespan (00:00:00) into a string???

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmartes
rmartes

ASKER

WOW! I thought I tried that already. Thanks so much.
Glad to help :-)