title: What string do I use to connect to an SQL Server?
body: <p>I'm trying to execute an SQL Job using a CRM Workflow by making a custom activity.  In my code, an online tutorial had me construct it like this (in c#):</p>
  
  <pre><code>[CrmWorkflowActivity("A test activity to run SQL Jobs")]
  public sealed class ExecuteSQLJob : System.Activities.CodeActivity
  {
  
      #region Inputs
      [Input("Job Name")]
      [Default("BMS_ExtractTransformLoad")]
      public InArgument&lt;String&gt; JobName { get; set; }
  
      [Input("Server Connection")]
      [Default("HBSSQL2008/MSSQLSERVER")]                  //&lt;--This String
      public InArgument&lt;String&gt; ServerName { get; set; }
  
      [Input("User Name")]
      [Default("-----")]
      public InArgument&lt;String&gt; UserName { get; set; }
  
      [Input("Password")]
      [Default("-----")]
      public InArgument&lt;String&gt; Password { get; set; }
      #endregion
  
      protected override void Execute(CodeActivityContext context)
      {
          Server server = new Server(ServerName.Get(context));   //&lt;--Is used here
          try
          {
              server.ConnectionContext.LoginSecure = false;
              server.ConnectionContext.Login = UserName.Get(context);
              server.ConnectionContext.Password = Password.Get(context);
              server.ConnectionContext.Connect();
              Job job = server.JobServer.Jobs[JobName.Get(context)];
              job.Start();
          }
          finally
          {
              if (server.ConnectionContext.IsOpen)
              {
                  server.ConnectionContext.Disconnect();
              }
          }
      }
  }
  </code></pre>
  
  <p>However, when I try to run this workflow, it throws an error saying it couldn't connect to the server.  (Specifically, the error is thrown on the server.ConnectionContext.Connect() method call).</p>
  
  <p>Is the problem the serverName String?  If so, how can I find out the correct serverName to use?</p>
  
  <p>Thanks for any help!</p>
  
  <p><strong>EDIT:</strong>
  Here's some additional info...</p>
  
  <p>This is how I got the server and instance name the first time:
  <img src="https://i.stack.imgur.com/d9lm8.png" alt="My SQL Query"></p>
  
  <p>And here's the error on the CRM Workflow:</p>
  
  <pre><code>Workflow suspended temporarily due to error: Unhandled Exception: Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server HBSSQL2008.
     at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
     at ExecuteSQLJob.ExecuteSQLJob.Execute(CodeActivityContext context)
     at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
     at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
  Inner Exception: System.Data.SqlClient.SqlException: Login failed for user 'rnkelch'.
     at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
     at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
     at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
     at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
     at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
     at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
     at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
     at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
     at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
     at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
     at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
     at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
     at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
     at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
     at System.Data.SqlClient.SqlConnection.Open()
     at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect(WindowsIdentity impersonatedIdentity)
     at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
  </code></pre>
  
  <p><strong>Sorry I didn't include this originally, thanks for your help so far</strong></p>