title: Visual Studio Server Explorer connects to database but in code an exception is thrown
body: <p>I have a very peculiar problem. In the VS2010 Server Explorer, I can connect to a SQL Server and execute a stored procedure just fine. However, when I try to do this in the code I get an exception thrown:</p>
  
  <blockquote>
    <p>The xp_cmdshell proxy account information cannot be retrieved or is
    invalid. Verify that the '##xp_cmdshell_proxy_account##' credential
    exists and contains valid information.</p>
  </blockquote>
  
  <p>Now maybe I used the wrong credentials in the code, but then I copied the connection string from the server explorer and put it into my connection string in my config file. Still, the same error.</p>
  
  <p>Here is the code that does the connecting and calling of the stored procedure:</p>
  
  <pre><code>public static DataSet callStoredProcedure(string procedure, params SqlParameter[] args)
  {
      SqlDataAdapter adapter = new SqlDataAdapter();
      DataSet dataSet = new DataSet();
  
      string connString = ConfigurationManager.ConnectionStrings["App"].ConnectionString;
  
      try
      {
          using (SqlConnection conn = new SqlConnection(connString))
          using (SqlCommand command = conn.CreateCommand())
          {
              conn.Open();
              if (args != null)
              {
                  foreach (SqlParameter param in args) command.Parameters.Add(param);
              }
              command.CommandText = procedure;
              command.CommandType = CommandType.StoredProcedure;
  
              adapter.SelectCommand = command;
              adapter.Fill(dataSet, "tabela");
          }
      }
      catch (SqlException exception)
      {
          throw new Exception("SqlClient exception", exception);
      }
  
      return dataSet;
  }
  </code></pre>
  
  <p>And here is the relevant config XML for the connection string, which is copied from the connection string the Server Explorer uses:</p>
  
  <pre><code>  &lt;connectionStrings&gt;
      &lt;add name="App" connectionString="Data Source=db2.myapp.com,49178\hosting;Initial Catalog=app;User ID=appuser;Password=f00barbaz" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Again, the Server Explorer can connect to the server and execute the stored procedure, but my code constantly throws the same Exception. What could be causing this?</p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT</strong><br>
  To make it clear: the Server Explorer <strong>can</strong> both connect and execute stored procedures with the same connection string that my code uses. Yet my code throws an exception. </p>