Q:

System.Data.SqlClient.SqlException occurred in System.Data.dll but was not handled in user code

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("data source=.; database=Sample; integrated security=SSPI");
        SqlCommand cmd = new SqlCommand("Select * from Table_1", con);
        con.Open();
        SqlDataReader rdr = cmd.ExecuteReader();
        GridView1.DataSource = rdr;
        GridView1.DataBind();
        con.Close();
    }
}

Whenever I run this code in VS-15, I receive following exception:

A:

The user your application is running under (check the App Pool) does not have permissions to access that database.
EDIT: Go to IIS and under Application Pools find the pool that your site is using. Click Advanced Settings and see what is under the Identity field. This is the user your process is running under. 
Next go to the SQL Management studio and check if that user exists under Security > Logins. 
If not, you should add it and make sure under User Mappings the Sample database is selected and the user is set as DBO for that DB.

