我正在嘗試顯示與我的數據庫連接的圖表。但它會產生一個錯誤。錯誤是「數據點插入錯誤,只能爲該數據系列設置1個Y值」。請幫幫我。 的代碼如下:數據點插入錯誤。此數據系列只能設置1個Y值
public partial class chart3 : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection(@"connectionString");
cmd = new SqlCommand("Select * from GraphChart",con);
da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
Chart1.DataSource = dt;
Chart1.DataBind();
}
}
來源:
<div>
<asp:Chart ID="Chart1" runat="server" CssClass="auto-style1" Width="423px">
<Series>
<asp:Series Name="Series1" XValueMember="Name"></asp:Series>
<asp:Series Name="Series2" YValueMembers="Age"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Title="Employee Data"></asp:Legend>
</Legends>
</asp:Chart>
</div>
您是否有示例數據和SQL /數據表定義?也許你有重複的名字,或者是存儲在錯誤列中的值 – Pieter21 2014-09-23 08:26:54
@ Pieter21:我有一個名爲「GraphChart」的表,它包含3列。他們是,1. NameId,2.名稱,3.年齡,它包含一些樣本值。例如:1,abc,10 – Vipin 2014-09-23 08:30:37
@ Pieter21:你有什麼想法爲什麼會發生這種錯誤。請幫幫我。 – Vipin 2014-09-23 08:33:15