Solved

Invalid cast from DateTime to Single.

Posted on 2004-10-20
5
851 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

17 Experts available now in Live!

Get 1:1 Help Now