title: SQL - Another "SELECT Permission was denied on the object" Issue
body: <p>(I know SO has well over a dozen questions with the same/similar title and I promise I've already gone through every one of them to no avail. I might have missed one or two minor details but I suspect my problem could be something more deep rooted. Enough said for intro)</p>
  
  <p>Anyway, I have a database (let's call it <code>FooDB</code>) that I restored from a backup database. I can do whatever I want with it using SQL Server 2012 Management Studio, including <code>SELECT</code>, <code>INSERT</code>, or <code>DELETE</code> on any of the record, columns, or tables.</p>
  
  <p>What I'm having trouble with is when I try to run a simple query against the same database, I get the following error:</p>
  
  <blockquote>
    <p>An error has occurred.","ExceptionMessage":"The SELECT permission was denied on the object 'BarTable', database 'FooDB', schema 'dbo'."</p>
  </blockquote>
  
  <p>There's a lot more to the stack trace but I won't post it here unless necessary. I'm using Visual Studio 2012 Ultimate and in one of the class files I specified the connection string as follows:</p>
  
  <pre><code>using (SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;" +
                                               "Initial Catalog=FooDB;" +
                                               "Integrated Security=true;"))
  {
      con.Open();
      using (SqlCommand command = new SqlCommand("SELECT TOP 3 * FROM BarTable", con))
          using (SqlDataReader reader = command.ExecuteReader())
          {
              while (reader.Read())
              {
                  ...  // code in this block is not shown as it is irrelevant to the issue
              }
          }
   }
  </code></pre>
  
  <p>Heeding to various suggestions I came across on SO, I tried the following:</p>
  
  <ul>
  <li><p>In SQL Server Management Studio, I selected 'Security' -> 'Logins' -> Right-click on the Windows login name and open the 'Properties' dialog -> In 'Server Roles' page, I selected <code>dbcreator</code>, <code>public</code>, <code>serveradmin</code>, <code>setupadmin</code>, and <code>sysadmin</code></p></li>
  <li><p>While on the same 'Properties' dialog from above, I selected 'User Mapping' page, then checked the 'Map' checkbox for the database (FooDB), and assigned the following database role membership: <code>db_accessadmin</code>, <code>db_backupoperator</code>, <code>db_datareader</code>, <code>db_datawriter</code>, <code>db_ddladmin</code>, <code>db_owner</code>, <code>db_securityadmin</code>, and <code>public</code></p></li>
  <li><p>From the Object Explorer of the Server Management Studio, I selected 'Databases' -> 'FooDB' -> 'Security' -> 'Users' -> Then I right-clicked the Windows login name and selected 'Properties' to open the 'Database User' dialog. Then I selected 'Owned Schemas' page and checked <code>db_backupoperator</code>, <code>db_datareader</code>, and <code>db_datawriter</code></p></li>
  <li><p>While on the same dialog from above, I selected 'Membership' page, and checked <code>db_accessadmin</code>, <code>db_backupoperator</code>, <code>db_datareader</code>, <code>db_datawriter</code>, <code>db_ddladmin</code>, <code>db_owner</code>, and <code>db_securityadmin</code></p></li>
  </ul>
  
  <p>That's all I can think of at this moment. Again, from within the SQL Server Management Studio (after logging in with the same Windows Authentication and server name) I can do whatever I want to with the database. But from within my C# class, it seems I can connect to the database but I lack the privilege to perform any action.</p>
  
  <p>This is something I've been wrestling with unsuccessfully for almost a week. What gives? </p>