0
我已经声明了,为什么我会得到一个错误?ASP.NET C#错误必须声明标量变量
conn.Open();
String strCount = "Select SUM(freight) AS TOTAL from Orders where EmployeeID = @employee AND Year(OrderDate)= @Oyear";
SqlCommand cmdCount = new SqlCommand(strCount, conn);
cmdSelect.Parameters.AddWithValue("@employee", DropDownList1.SelectedValue.ToString());
cmdSelect.Parameters.AddWithValue("@Oyear", RadioButtonList1.SelectedValue.ToString());
double intCount = (double)cmdCount.ExecuteScalar();
Label1.Text = intCount.ToString();
conn.Close();
什么是你的命令对象的名称? 'cmdCount'或'cmdSelect'? – SearchAndResQ
你应该看看[我们可以停止使用AddWithValue()了吗?](http://blogs.msmvps.com/jcoehoorn/blog/2014/05/12/can-we-stop-using-addwithvalue-already/)并停止使用'.AddWithValue()' - 它可能会导致意外和令人惊讶的结果... –
没有用.AddWithValue()我们可以使用什么方法来解决? –