Bug #103312 MysqlHelper.executenonquery dont return affected rows correctly
Submitted: 13 Apr 21:50 Modified: 14 Apr 13:12
Reporter: mohamed atef Email Updates:
Status: Analyzing Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.23 OS:Microsoft Windows
Assigned to: MySQL Verification Team CPU Architecture:Any
Tags: mysqlhelper.executenonquery

[13 Apr 21:50] mohamed atef
Description:
when using insert into table on duplicate key update 
mysqlhelper.executenonquery don`t return the affected rows correctly
in dotnet connector version 8.0.23

How to repeat:
open workbench
create table 
CREATE TABLE `testignore` (
  `Id` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT  INTO `abc`.`testignore` (`Id`) VALUES ('1');
INSERT  INTO `abc`.`testignore` (`Id`) VALUES ('2');
then
SELECT * FROM abc.testignore;
2 row(s) returned;

then 
INSERT  INTO `abc`.`testignore` (`Id`) VALUES ('1') on duplicate key update Id=Id;
0 row(s) affected;

INSERT  INTO `abc`.`testignore` (`Id`) VALUES ('2') on duplicate key update Id=Id;
0 row(s) affected;

create windows form application
add mysql.data dll as refernce

private void button1_Click(object sender, EventArgs e)
        {
            string SQLADD = "INSERT  INTO `abc`.`testignore` (`Id`) VALUES (@P1) on duplicate key update Id=Id ;";
            try
            {
                int[] lst = new int[]
                {
                    1,2
                };
                foreach (int u in lst)
                {
                    MySqlParameter[] PARA = new MySqlParameter[]
                       {
                        new MySqlParameter(){ ParameterName="P1",MySqlDbType=MySqlDbType.Int32,Value= u }
                       };
                    int i = MySqlHelper.ExecuteNonQuery(MyCurrentConnString(), SQLADD, PARA);
                    MessageBox.Show(i.ToString());
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private string MyCurrentConnString()
        {
            MySqlConnectionStringBuilder cons = new MySqlConnectionStringBuilder
            {
                Server = "127.0.0.1",
                Port = 3306,
                UserID = "root",
                Password = "yousef",
                Database = "abc",
                ConvertZeroDateTime = true,
                SslMode = MySqlSslMode.None,
                AllowUserVariables = true
            };
            return cons.ToString();
        }

every time i value will be shown as 1 although 0rows affected

Suggested fix:
i don`t know
[14 Apr 13:12] mohamed atef
MySqlCommand.ExecuteNonQuery()
Also return Invalid Affected Rows