Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2111
  • Last Modified:

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
0
rmartes
Asked:
rmartes
  • 2
1 Solution
 
CodeCruiserCommented:
What happens if you use

dbReader("time_in_do_not_disturb").ToString()
0
 
rmartesAuthor Commented:
WOW! I thought I tried that already. Thanks so much.
0
 
CodeCruiserCommented:
Glad to help :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now