如何正確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