I have written a plugin that fires off when new record is created (post). This plugin simple runs a SSIS package that moves newly created record details in to SQL table. I'm having to deploy this plugin as none isolation mode.
What I want to know is that is there any better solution to live sync CRM records with SQL table?
I am working on CRM 2011 RU 18 On premise.
string connectionString = "User Id=username; Password=password; Initial Catalog=db; Data Source=myServer;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("INSERT INTO testPerson (Firstname, Lastname, Emailaddress, CrmGuid) VALUES (@FN, @LN, @Email, @CrmGuid)");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("@FN", "James");
cmd.Parameters.AddWithValue("@LN", "Bolton");
cmd.Parameters.AddWithValue("@Email", "[email protected]");
cmd.Parameters.AddWithValue("@CrmGuid", "C45843ED-45BC-E411-9450-00155D1467C5");
connection.Open();
cmd.ExecuteNonQuery();
}
//////// Direct DB Connection //////////// <--- END 1
}
catch (Exception ex)
{
tracingService.Trace("CRM to mWeb Sync Plugin: {0}", ex.ToString());
throw;
}