Solved

Invalid cast from DateTime to Single.

Posted on 2004-10-20
5
860 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 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

10 Experts available now in Live!

Get 1:1 Help Now