Solved

Time Field to Label

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

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

18 Experts available now in Live!

Get 1:1 Help Now