enter image description hereI可以使用没有参数的存储过程在C#Winforms中填充图表控件,这很好。但是现在我需要使用带参数的存储过程。有什么建议怎么做?
下面是我的代码如何使用没有参数的存储过程填充图表控件。
sqlCon.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlCon;
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter myCommand = new SqlDataAdapter("[Proc1]", sqlCon);
DataSet ds = new DataSet();
myCommand.Fill(ds);
DataView source = new DataView(ds.Tables[0]);
chart1.DataSource = source;
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.Series[0].XValueMember = "Pojazd";
chart1.Series[0].YValueMembers = "Suma";
chart1.DataBind();
请帮我 :-)
只是对@Rakitić所说的进一步解释。
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@PARAMNAME", SqlDbType.VarChar,10).Value = paramValue;
然后,您需要在存储过程中添加此参数。我只是猜测你正在使用Sql Server:
@PARAMNAME varchar(10)