I want to store some values in my database based on if the user email exists in my table or not.

This is the code:

```
SqlConnection con = new SqlConnection(@"Data Source=SAMA-PC\SQLEXPRESS;Initial Catalog=advCenter;Integrated Security=True");
        int str = 0;
        SqlCommand com2 = new SqlCommand("select [user_Account] from [User] where [user_Email]=@s", con);
        com2.Parameters.AddWithValue("@s", Convert.ToString(Session["mail"]));
        SqlDataReader rd;
        con.Open();
        rd = com2.ExecuteReader();
        if (rd.HasRows)
        {
                con.Close();
                con.Open();
                str = Convert.ToInt32(rd["user_Account"]);
                str = str + 30;
                SqlCommand co = new SqlCommand("update [User] set [user_Account]=@ua WHERE [user_Email]=@em", con);
                co.Parameters.AddWithValue("@ua", str);
                co.Parameters.AddWithValue("@em", Convert.ToString(Session["mail"]));
                co.ExecuteNonQuery();
                con.Close();
        }
        else
        {
            SqlCommand c = new SqlCommand("insert into [User] values(@e,@s,@a)", con);
            c.Parameters.AddWithValue("@e", Session["mail"].ToString());
            c.Parameters.AddWithValue("@s", "logged in");
            c.Parameters.AddWithValue("@a", "30");
            con.Open();
            c.ExecuteNonQuery();
            con.Close();
        }

```

but while running the code I get the error `Invalid attempt to call MetaData when reader is closed.` at this line:

```
str = Convert.ToInt32(rd["user_Account"]);

```

What can i do to solve it? I tried more and more in `con.open()` and `con.close()` but each time I get the error saying that `reader` is closed or that `reader` associated whith line that is closed too.