首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#mschart连接sql数据库步骤

2014-01-03 
c#mschart连接sql数据库方法求c#mschart连接sql数据库方法(winform)在图表中连接数据库,根据数据库中的参

c#mschart连接sql数据库方法
求c#mschart连接sql数据库方法(winform)在图表中连接数据库,根据数据库中的参数变化图中的柱形也变化,多个柱形,谢谢
[解决办法]

  string connStr = "server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs";
        SqlConnection myConn = new SqlConnection(connStr);
        string selStr = "select 帐号,count(帐号) as 次数 from pub_log_read group by 帐号 order by 帐号 desc";
        SqlCommand myCmd = myConn.CreateCommand();
        myCmd.CommandText = selStr;
        myConn.Open();
        SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection);

        // Since the reader implements and IEnumerable, pass the reader directly into
        // the DataBindTable method with the name of the Column to be used as the XValue
        Chart1.Series[0].Points.DataBindXY(sdr, "帐号",sdr,"次数");

        sdr.Close();
        myConn.Close();

热点排行