使用VS中devexpress的chartcontrol控件画折线图,为什么最后一条设置纵坐标语句报错: The type of the "学号" value data member isn't compatible with the numeric scale.”
我试了一下,如果数据库中纵坐标字段设置为整形就不报错,其他类型就不行。
是不是要设置y轴属性呀,但找了很久也没有找到地方,求帮助。谢谢
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.XtraCharts;
namespace ChartControl
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
Bind();
}
public void Bind()
{
Series s1 = this.chartControl1.Series[0];
SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
scsb.DataSource = "SK-20220626HGWR";
scsb.InitialCatalog = "test";
scsb.UserID = "sa";
scsb.Password = "123456";
SqlConnection con = new SqlConnection(scsb.ToString());
con.Open();
string str = "Select*from students";
SqlDataAdapter sda = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
sda.Fill(ds);
s1.DataSource = ds.Tables[0];
s1.ArgumentDataMember = "年龄";
s1.ValueScaleType = ScaleType.Numerical;
s1.ValueDataMembers[0] = "学号";
}
}
}