Solved

Time Field to Label

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 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