Solved

Time Field to Label

Posted on 2011-09-13
2
324 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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