VB.Net Timespan to String

Posted on 2012-08-28
Last Modified: 2012-08-28
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)
End If

Open in new window

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

Question by:rmartes
    LVL 83

    Accepted Solution

    What happens if you use


    Author Closing Comment

    WOW! I thought I tried that already. Thanks so much.
    LVL 83

    Expert Comment

    Glad to help :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now