title: An exception of type 'System.InvalidOperationException' occurred in System.Data.dll that inserting data into Gridview
body: <p>I try to read session varible <code>Id</code> on myconferences page and fill the Gridview with my query but I got error that 'System.InvalidOperationException' from <code>cmd.ExecuteNonQuery()</code>. How to fix it?<br> 
  <a href="https://i.stack.imgur.com/yUR0k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yUR0k.png" alt="enter image description here"></a></p>
  
  <p><br> My codes</p>
  
  <pre><code> public partial class MyConferences : System.Web.UI.Page
  {
      internal User user;
  
      protected void Page_Load(object sender, EventArgs e)
      {
          if(!IsPostBack)
          {
              BindGrid();
  
          }
      }
  
      private void BindGrid()
      {
          object user = Session["Id"];
  
          if(user != null)
          {
              user = Session["user"] as User;
          }
  
          string constr = ConfigurationManager.ConnectionStrings[0].ConnectionString;
          using(SqlConnection con = new SqlConnection(constr))
          {
              string query = "select Conferences.conferenceName , Conferences.conferencePlace , Conferences.conferenceDate , Conferences.category from Conferences inner join Users on Conferences.fk_Users = Users.Id where Users.Id =@Id";
  
              using(SqlCommand cmd = new SqlCommand(query))
              {
  
                  cmd.Connection = con;
                  cmd.Parameters.AddWithValue("@Id", ((object)user) ?? DBNull.Value);
                  con.Open();
                  GridView1.DataSource = cmd.ExecuteReader();
                  GridView1.DataBind();                    
                  cmd.ExecuteNonQuery();
                  con.Close();
              }
          }
      }
  }
  </code></pre>
  
  <p>Also User object on Login page.</p>
  
  <pre><code>  User u = new User();
                  u.UserId = Convert.ToInt32(dr["Id"]);
                  u.Name = dr["name"] != DBNull.Value ? dr["name"].ToString() : string.Empty;
                  u.Surname = dr["surname"] != DBNull.Value ? dr["surname"].ToString() : string.Empty;
                  u.Email = dr["email"] != DBNull.Value ? dr["email"].ToString() : string.Empty;
                  Session["user"] = u;
  </code></pre>