title: A chart element with the name 'John' already exists in the 'SeriesCollection'
body: <p>I am following <a href="http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx" rel="nofollow noreferrer">this post</a>, to build a <code>bar chart</code> and show on my webpage. Below is the code i have done to accomplish it:</p>
  
  <pre><code>SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);            
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = con;
  cmd.CommandText = "select * from ForChart";
  cmd.CommandType = CommandType.Text;            
  
  SqlDataAdapter adp = new SqlDataAdapter();
  adp.SelectCommand = cmd;
  DataSet myDataSet = new DataSet();
  adp.Fill(myDataSet, "Query");
  
  foreach (DataRow row in myDataSet.Tables["Query"].Rows)
  {
      string seriesName = row["SalesRep"].ToString();
      Chart1.Series.Add(seriesName);
      Chart1.Series[seriesName].ChartType = SeriesChartType.Line;
      Chart1.Series[seriesName].BorderWidth = 2;
      for (int colIndex = 1; colIndex &lt; myDataSet.Tables["Query"].Columns.Count; colIndex++)
      {
          string columnName = myDataSet.Tables["Query"].Columns[colIndex].ColumnName;
          string YVal = Convert.ToString(row[columnName]);
          Chart1.Series[seriesName].Points.AddXY(columnName, YVal);
      }
  }
  
  GridView1.DataSource = myDataSet;
  GridView1.DataBind();
  cmd.Connection.Close();
  </code></pre>
  
  <p>And my table is having the below data. Please check the snapshot</p>
  
  <p><img src="https://i.stack.imgur.com/Ri2Zr.jpg" alt="enter image description here"></p>
  
  <p><strong>But when i run the code i am getting the below error. Please help me to resolve the issue:</strong></p>
  
  <p><strong>A chart element with the name 'John' already exists in the 'SeriesCollection'.</strong></p>
  
  <p>I am not able to <strong>traverse</strong> the records thats why i am getting this error, but i don't know how to traverse through all the records. </p>
  
  <p><strong>Coding help would be very much appreciated. Thanks.</strong></p>