cannot read multiple rows from sqldatareader
        Posted  
        
            by amby
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by amby
        
        
        
        Published on 2010-04-15T21:09:17Z
        Indexed on 
            2010/04/15
            21:13 UTC
        
        
        Read the original article
        Hit count: 343
        
Hi, when i query for only one record/row, sqldatareader is giving correct result but when i query for multiple rows, its giving error on the client side. below is my code. please tell me what is the problem here.
    string query = "select * from Customer_Order where orderNumber = " + order;//+" OR orderNumber = 17";
DataTable dt = new DataTable();
            Hashtable sendData = new Hashtable();
        try
            {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, conn))
                {
                    conn.Open();
                    SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                    dt.Load(dr);
                }
            }
        © Stack Overflow or respective owner