如何正确declair在下面的代码的参数。即时得到的“的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);
}
}
你的IDE是足够聪明,没有如果没有,则弹出的属性列表。你是怎么写这样的陈述的? – Lion 2011-12-31 00:41:59
+1抵消随机-1(不解释)为'using'声明 – 2011-12-31 00:50:55