Results 1 to 2 of 2

Thread: Reader Error

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Reader Error

    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;
    }
    Last edited by Memnoch1207; Oct 14th, 2003 at 10:22 AM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width