报的错是这个:
然后我的后台代码是如下,起初没有任何错误提示,但是按下F11调试后就出现上面的错误了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web.UI.DataVisualization.Charting;
namespace zhu
{
public partial class WebForm1 : System.Web.UI.Page
{
private SqlConnection SqlConnString;
string[] Count1 = new string[9];
double[] Count2 = new double[9];
//string[] Count3 = new string[11];
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
string vOutParam = "";
ds = ExeProcDT3("Searchtable5", "", ref vOutParam);
if (ds.Tables.Count >0)
{
DataTable dt = new DataTable();
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < 9; i++)
{
Count2[i] = Convert.ToDouble(dt.Rows[i]["AM"]);
Count1[i] = dt.Rows[i]["c"].ToString() + dt.Rows[i]["a"].ToString();
}
}
}
zhuzhaugntu(Count1, Count2);
}
//柱状图图形的设置
private void zhuzhaugntu(string[] a, double[] b)
{
Chart1.ChartAreas[0].BackColor = Color.Black;//设置背景为黑色
Chart1.ChartAreas[0].Area3DStyle.PointGapDepth = 10;//x轴行间距
Chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;//需线
Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Yellow;//需线颜色
Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;//关掉竖线1
//根据水尺最高值设置Y轴间距
Chart1.ChartAreas[0].AxisY.Maximum = 5000;
Chart1.Series[0].Label = "#VAL";//设置标签文本 (在设计期通过属性窗口编辑更直观)
Chart1.Series[0].IsValueShownAsLabel = true;//显示标签
Chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Blue;
Chart1.ChartAreas[0].AxisX.LabelAutoFitMaxFontSize = 12;
Chart1.ChartAreas[0].AxisY.LabelAutoFitMaxFontSize = 15;
Chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Red;
Chart1.Series[0].Points.DataBindXY(a, b);//初始化数据
/*Chart1.Series[1].Label = "#VAL";
Chart1.Series[1].IsValueShownAsLabel = true;
Chart1.ChartAreas[0].AxisX2.LabelStyle.ForeColor = Color.Blue;
Chart1.ChartAreas[0].AxisX2.LabelAutoFitMaxFontSize = 12;
Chart1.Series[0].Points.DataBindXY(c);*/
}
//连接数据库
private SqlConnection GetConnect()
{
string strSqlSqlConn = "Data Source=.;Initial Catalog=plc;" +
"Persist Security Info=True;User ID=Jerome;Password=123456";
SqlConnection sqlConnString = new SqlConnection(strSqlSqlConn);
return sqlConnString;
}
/// <summary>
/// 执行单入存过带多个表
/// </summary>
/// <param name="procName">存储过程名称</param>
/// <param name="vInParam">输入参数</param>
/// <param name="vOutParam">输出参数</param>
/// <returns></returns>
public DataSet ExeProcDT3(string procName, string vInParam, ref string vOutParam)
{
try
{
SqlConnString = GetConnect();
SqlCommand SqlCmd = new SqlCommand(procName, SqlConnString);
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlCmd.Parameters.Add("@inparam", SqlDbType.VarChar, 1000).Value = vInParam;
SqlCmd.Parameters.Add("@outparam", SqlDbType.VarChar, 1024).Direction = ParameterDirection.Output;
SqlDataAdapter SqlDa = new SqlDataAdapter(SqlCmd);
DataSet DS = new DataSet();
SqlDa.Fill(DS);
vOutParam = SqlCmd.Parameters["@outparam"].Value.ToString();
return DS;
}
catch (Exception)
{
return null;
}
finally
{
SqlConnString.Close();
}
}
}
}