laiseng Posted June 20, 2007 Report Share Posted June 20, 2007 I've had this problem of getting "Input string was not in a correct format." from dataset queried from my local MSSQL 2005 database. The following is my simple code that i've modded from the "C:\Program Files\Chart FX for Visual Studio 2005\Help and Samples\Sample Applications\Windows Forms\PassingData" project ResetChart(); chart1.Gallery = Gallery.HighLowClose; SqlConnection con = new SqlConnection(); con.ConnectionString = (@"Data Source=REPOSITORY\REPOSITORY;Initial Catalog=PSP;Persist Security Info=True;User ID=endinggame;Password=spassword;"); SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandText = "SELECT DocumentType, sum(FileSize) AS FileSize FROM TB_FileUpload GROUP BY DocumentType"; com.CommandType = CommandType.Text; DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(); ad.SelectCommand = com; con.Open(); ad.Fill(ds); con.Close(); FieldMap dt = new FieldMap(); dt.Usage = FieldUsage.XValue; dt.Name = "DocumentType"; dt.DisplayName = "doc"; FieldMap fs = new FieldMap(); fs.Usage = FieldUsage.Value; fs.Name = "FileSize"; fs.DisplayName = "size"; chart1.DataSourceSettings.Fields.Add(dt); chart1.DataSourceSettings.Fields.Add(fs); chart1.DataSourceSettings.DataSource = ds.Tables[0]; //ERROR "HERE Input string was not in a correct format." the query return two colum only that is DocumentType(string) and FileSize(int) Link to comment Share on other sites More sharing options...
Frank Posted June 20, 2007 Report Share Posted June 20, 2007 The following code: FieldMap dt = new FieldMap(); dt.Usage = FieldUsage.XValue; dt.Name = "DocumentType"; Is instructing Chart FX to use th eDocumnetType column as X-Values for your chart. Is this a numeric column? Only numeric and DateTime columns can be used as X-Values. If what you want is to use it as X-Axis labels then use FieldUsage.Label instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.