Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Invalid cast from DateTime to Single.

Posted on 2004-10-20
5
864 Views
Last Modified: 2012-08-13
Hi im having a problem using asp.net web matrix

trying to bind results to a web grid.

gives me the error on the topic

Code i have is as follows:

Sub Page_Load(o as object, e as EventArgs)
  Dim reader As IDataReader = GetReader()

  Dim chart As New SmoothLineChart()
  chart.DataXValueField = "profit"
  chart.DataYValueField = "date"
  chart.DataSource = reader
  chart.DataBind()
  reader.Close()

  ChartControl1.Charts.Add(chart)
  ChartControl1.RedrawChart()
End Sub

Function GetReader() As IDataReader
  Dim connection As new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\PATH TO DB")
  Dim command As new OleDbCommand("SELECT *from DB where a.camp_id = 'INACT01'", connection)
  connection.Open()
  Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function


im getting the error on the following Line 14

Exception Details: System.InvalidCastException: Invalid cast from DateTime to Single.

Source Error:


Line 12:       chart.DataYValueField = "date"
Line 13:       chart.DataSource = reader
Line 14:       chart.DataBind()
Line 15:       reader.Close()
Line 16:    
 
Anyone can help me?

Thx in advance
0
Comment
Question by:ridi786
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 12357975
DataYValueField  is intger or single and you are trying to assign to a datetime field and thats why your gettign this error. Put a differenet value i.e. other than date on DataYValueField and see first.
0
 
LVL 1

Author Comment

by:ridi786
ID: 12358145
but i wana see movement by month, so i need it there. any way to format it as date?
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12358369
Is it possible to make DataYValueField  as date ? I ahev no idea abotu SmoothLineChart, where did you get it ?
0
 
LVL 20

Accepted Solution

by:
jitganguly earned 500 total points
ID: 12358449
0
 
LVL 1

Author Comment

by:ridi786
ID: 12358758
Well i tried the Tutorial

That doesnt give me much info. I know about that and searched his site or tried to evn.

He just give me types to check @ this URL

ChartControl1.YValuesFormat = "{0:N}"
       
You can see all the formats in here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp 
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Title # Comments Views Activity
Query to get the soonest date out of a few records 2 51
ASP Focus problem 3 67
Hide cell in a table 2 27
Html fieldset fix its height and width 4 30
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…

856 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