I've been desperately trying to find a way to notify the client of changes in the database.
I tried TableDependency Package but then noticed that that uses SQL and not MYSQL. I stumbled upon Devart and they have the same thing. I've installed the package and set up some code to test if it actually receives notification when there is a change in the database. But when I try to run it returns me the exception:
Devart.Common.LicenseException: 'Feature is not supported.
Here's the code i use for testing:
namespace WpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public string connectionString = @"server=198.23.60.117;user=*******;database=*******;password=*******";
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Devart.Data.MySql.MySqlConnection DependencyConn = new Devart.Data.MySql.MySqlConnection(connectionString);
Devart.Data.MySql.MySqlCommand FriendsDependencyCommand = new Devart.Data.MySql.MySqlCommand("SELECT user_two FROM friends WHERE user_one=@username", DependencyConn);
MySqlDependency dependency = new MySqlDependency(FriendsDependencyCommand, 100);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
DependencyConn.Open();
MySqlDependency.Start(connectionString);
}
void dependency_OnChange(object sender, Devart.Data.MySql.MySqlTableChangeEventArgs e)
{
MessageBox.Show("Database Changes Detected.");
}
}
public class Customer
{
public string Username { get; set; }
}
}
I should have the needed Dependency's I installed the package using the NuGet Package Manager.
Any clues? I'd really appreciate.