Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:33:54+00:00 2026-06-06T18:33:54+00:00

I’m trying to execute an SQL Job using a CRM Workflow by making a

  • 0

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#):

[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<String> JobName { get; set; }

    [Input("Server Connection")]
    [Default("HBSSQL2008/MSSQLSERVER")]                  //<--This String
    public InArgument<String> ServerName { get; set; }

    [Input("User Name")]
    [Default("-----")]
    public InArgument<String> UserName { get; set; }

    [Input("Password")]
    [Default("-----")]
    public InArgument<String> Password { get; set; }
    #endregion

    protected override void Execute(CodeActivityContext context)
    {
        Server server = new Server(ServerName.Get(context));   //<--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();
            }
        }
    }
}

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).

Is the problem the serverName String? If so, how can I find out the correct serverName to use?

Thanks for any help!

EDIT:
Here’s some additional info…

This is how I got the server and instance name the first time:
My SQL Query

And here’s the error on the CRM Workflow:

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()

Sorry I didn’t include this originally, thanks for your help so far

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:33:55+00:00Added an answer on June 6, 2026 at 6:33 pm

    Ok, I think I figured it out now.

    Because there is only one instance of SQL running on our server, I don’t actually need to use the ServerName\InstanceName format. Both hbssql2008 and HBSSQL2008 allow me to connect. In addition, the IP works as well.

    Also, another issue I came across was the the user name and password I was using was from Windows Integrated Security, not the sql server’s security. Therefore, I created a new account on the server with appropriate permissions and sql security info and it allowed me to connect.

    Thank you all for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.