Visual Studio에서 C#을 사용하여 첫 번째 차트를 작성하고 있습니다. 차트와 데이터베이스를 만들고 그 사이에 연결을 만들었습니다. 데이터베이스에는 "DrukSensor"(float) 및 "DateTime"(DateTime)이라는 두 개의 열이 있습니다.C# 차트 시리즈 오류
제 코드에서는 x 축에 DateTime, Y 축에 Druksensor가있는 차트를 만들고 싶습니다.
그러나 내 코드를 시도 할 때 다음과 같은 오류가 발생합니다. 시리즈 요소에 "Druksensor"라는 이름의 차트 요소가 없습니다.
웹 서핑을 시도하여 올바른 anwser를 찾았지만 불행하게도 찾을 수 없었습니다. 나는 누군가가 내 첫 번째 차트 빌드를 도와 줄 수 있기를 바랍니다
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=LP12;Initial Catalog=SmmsData;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("Select DrukSensor,DateTime from SysteemSensorInfo2", con);
SqlDataReader myreader;
DataSet ds = new DataSet();
new SqlDataAdapter(cmd).Fill(ds);
myreader = cmd.ExecuteReader();
Chart1.Series["DrukSensor"].Points.AddXY(myreader.GetDateTime(Int32.Parse("DateTime")), myreader.GetFloat(Int32.Parse("DrukSensor")));
Chart1.DataSource = ds;
Chart1.DataBind();
}
:
여기 내 코드입니다.
미리 감사드립니다.
설명없이 코드를 게시하십시오. – TaW