Jump to content
Software FX Community

Input string was not in a correct format. MSSQL DATASET


Recommended Posts

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


  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;


  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.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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...