?
Solved

Invalid cast from DateTime to Single.

Posted on 2004-10-20
5
Medium Priority
?
875 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 1500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

771 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