I am getting a couple of errors in my page_load event
First Error:
Cannot implicitly convert type 'int' to 'System.Data.SqlClient.SqlDataReader'
Second Error:
Operator '>=' cannot be applied to operands of type 'object' and 'int'
any ideas??? I am trying to return a count from the sql query, then check with the reader if that count is greater than 2.
Code:private void Page_Load(object sender, System.EventArgs e) { string strConn = "Data Source=localhost;uid=steve;pwd=xxxxxx;Initial Catalog=mansion"; SqlConnection Conn = new SqlConnection(strConn); SqlCommand Comm = new SqlCommand("SELECT rDate, COUNT(rDate) AS 'count' FROM reservations GROUP BY(rDate) HAVING COUNT(rDate) > 1", Conn); SqlDataReader reader; reader = Comm.ExecuteNonQuery();<------ First Error while(reader.Read()) { if(reader["count"] >= 2)<------------ Second Error { Calendar1.SelectedDates.Add(Convert.ToDateTime(reader["rDate"])); } } reader.Close(); Conn.Close(); Conn = null; }




Reply With Quote