SqlConnection giving object reference error
<p>I have to use connection string for my query, but I am getting an error </p>

<blockquote>
  <p>object reference not set to an instance of an object.</p>
</blockquote>

<p>This is my code:</p>

<pre><code>string strSql = "select first_name + ' ' + last_name name, email from user_mst where mkey in (" + Session["UserId"].ToString() + ")";

DataTable table = new DataTable();

using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString()))
{
    conn.Open();

    using (SqlDataAdapter dbdata = new SqlDataAdapter(strSql, conn))
    {
        dbdata.Fill(table);
    }

    conn.Close();
}
</code></pre>

<p>I get error at</p>

<pre><code>SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString()))
</code></pre>

<p>but my connections seems to be exactly fine.</p>