Solved

Time Field to Label

Posted on 2011-09-13
2
323 Views
Last Modified: 2012-05-12
Hi all,

I have a label, and I retrieve a value from the database that is a TIME field.

When assigning the value to the label as:

Label1.Text=rs(0)

I get the following error:

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

I tried

Label1.text = CStr(RS(0))

But still not working.

Any help will be appreciated :)

Thanks!
0
Comment
Question by:pvg1975
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36532210
rs(0) is a TimeSpan object, an it contains a lot of information.

You first need to decide with information you need:

rs(0).Minutes
rs(0).Days

and so on.

if you do not want to retrieve an exact value such as those, tell the variable to retrieve a String representation of what is inside the variable this way:

Label1.Text = rs(0).ToString
0
 

Author Closing Comment

by:pvg1975
ID: 36532242
Thanks James!

Im posting another question in the next 2 minutes (similar to this)

Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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