如何在下面的代码中正确声明参数。我在“SelectCommand”上得到下划线我不确定我做错了什么。
public int GetTotalNumberOfAprovedPictureIds(string SexType)
{
string strConectionString = ConfigurationManager.AppSettings["DataBaseConnection"];
SqlConnection conn = new SqlConnection(strConectionString);
conn.Open();
SqlCommand oCommand = new SqlCommand("SELECT COUNT(1) AS Expr1 FROM MEMBERS INNER JOIN Picture ON MEMBERS.MemberID = Picture.MemberID WHERE (Picture.PicAproval = 1) AND (Picture.PicArchive = 0) AND (MEMBERS.MemberSex = @dSexType)", conn);
object oValue = oCommand.ExecuteScalar();
oCommand.SelectCommand.Parameters.Add("@dSexType", SqlDbType.Text);
oCommand.SelectCommand.Parameters["@dSexType"].Value = SexType;
conn.Close();
if (oValue == DBNull.Value)
{
return 0;
}
else
{
return Convert.ToInt32(oValue);
}
}