Using "WHERE" in command with MySQLDependecy

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
killerowns
Posts: 1
Joined: Thu 18 Oct 2018 22:02

Using "WHERE" in command with MySQLDependecy

Post by killerowns » Thu 18 Oct 2018 22:07

Hi, I'm testing the dotnet conector for mysql and I'm trying to fire OnChange handler in a WHERE statement in my sql command but when I update, insert or delete something in table wich is not in WHERE statement, the envent fires even.

This is my code:

void Start()
{
MySqlConnection connection = new MySqlConnection(constring);
connection.Open();
MySqlCommand Orcamento_Cadastrado = new MySqlCommand("SELECT id, usuario_id, mensagem, lida, data, negocio_id FROM mensagem_usuario WHERE id='0'", connection);

MySqlDependency dependency = new MySqlDependency(Orcamento_Cadastrado, 100);

dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
MySqlDependency.Start(constring);
}

Is there a way to do this or what I'm doing wrong?

Pinturiccio
Devart Team
Posts: 2406
Joined: Wed 02 Nov 2011 09:44

Re: Using "WHERE" in command with MySQLDependecy

Post by Pinturiccio » Wed 24 Oct 2018 15:42

MySqlDependency tracks changes for the whole table. It's not possible to track changes only in some specific records. It is not designed for this purpose.

Post Reply