Business Logic Assembly not able to connect to subscriber

  • Not sure if this should be in the Replication section but since its related to custom coding with .Net I figure this is the best place. We are working on a SQL Server 2005 Replication project that has to use custom business logic to handle which records are to get merged to the publisher.

    When a new record is sent from the Publisher to the subscriber it's able to make the connection to the subscriber in the Initialize() function so the handlers can verify that the record is valid for insertion.

    When the Subscriber goes to upload a new record to the publisher it's not able to make a connection to the subscriber in the Initialize() function. We get the default error that SQL 2005 gives if it cant make a connection. I have the code we are testing with below.

    Has anyone ran into this type of problem before? or are we going about this in the wrong way. Our goal is to allow what we called Completed Accounts to get published to the subscribers through the SQL Filters and the same thing goes for accounts coming from the subscribers. We only want completed accounts from them and any incomplete accounts should stay with that subscribers until its marked complete. We tried using just the filters on the publisher but it would delete all the incomplete accounts on the subscriber when a replication was executed.

    // Implement the Initialize method to get publication

    // and subscription information.

    public override void Initialize(

    string publisher,

    string subscriber,

    string distributor,

    string publisherDB,

    string subscriberDB,

    string articleName)

    {

    SqlConnectionStringBuilder pubString = new SqlConnectionStringBuilder();

    pubString.InitialCatalog = publisherDB;

    pubString.DataSource = publisher;

    pubString.IntegratedSecurity = false;

    pubString.UserID = "UserID";

    pubString.Password = "Password";

    // Create a connection to the Publisher.

    connectionPub = new SqlConnection(pubString.ToString());

    try

    {

    // Open the connection to the Publisher.

    connectionPub.Open();

    }

    catch (Exception ex)

    {

    //Custom error log function

    Write_Log("Publisher Initialize Error: " + ex.Message + " Client " + connectionPub.ConnectionString);

    }

    SqlConnectionStringBuilder subsString = new SqlConnectionStringBuilder();

    subsString.InitialCatalog = subscriberDB;

    subsString.DataSource = subscriber;

    subsString.IntegratedSecurity = false;

    subsString.UserID = "UserID";

    subsString.Password = "Password";

    // Create a connection to the Subscriber.

    connectionSubs = new SqlConnection(subsString.ToString());

    try

    {

    // Open the connection to the Subscriber.

    connectionSubs.Open();

    }

    catch (Exception ex)

    {

    //Custom error log function

    Write_Log("Subscriber Initialize Error: " + ex.Message + " Client " + connectionSubs.ConnectionString);

    }

    }

  • What type of CLR object is this? A Trigger/Stored Procedure?

    Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
    My Blog | Twitter | MVP Profile
    Training | Consulting | Become a SQLskills Insider
    Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]

  • Its a .Net assembly (*.dll) file, Its needed to over ride merge replication data changes and conflicts. Like Inserts, Updates, and Deletes.

  • There is no way to make a connection to the subscriber when going through Web Sync's even though its an SSL connection.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply