Solved

Invalid cast from DateTime to Single.

Posted on 2004-10-20
5
871 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
[X]
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
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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/…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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