Update record with identical value raise exception

Update record with identical value raise exception

Postby mayash75 » Sun 15 Jul 2012 12:34

Hello,

I have noticed that in MySQL, when you make a change to a record but the changes are actually identical to the original record (that is, taking a field with value “miki” and telling mysql to alter the content to “miki” ) it returns 0 rows affected.

This makes entity framework throw an exception.
I wonder if you are familiar with it... ?
Can you prevent such exception from raise at the dotConnect level?


Another question regarding entity framework migrations:

Currently I edit my migration classes to refer to the relevant database using Sql command for MySQL:
Sql("USE databaseName");
However, while this will work for MySQL, it will fail for Oracle / MsSql.
Is there a devart method to do that?

Best Regards,
Maya.
mayash75
 
Posts: 2
Joined: Sun 03 Jun 2012 15:48

Re: Update record with identical value raise exception

Postby Shalex » Thu 19 Jul 2012 17:00

mayash75 wrote:when you make a change to a record but the changes are actually identical to the original record it returns 0 rows affected.
This makes entity framework throw an exception.

Please include the "Found Rows=true;" entry in your connection string to fix the issue.
The Found Rows connection string parameter determines whether the provider will return the number of rows matched by the WHERE condition of the UPDATE statement instead of the rows actually changed. Default value is false.
This feature was implemented in dotConnect for MySQL starting from the 7.0.25 version: http://www.devart.com/dotconnect/mysql/revision_history.html .

mayash75 wrote:Currently I edit my migration classes to refer to the relevant database using Sql command for MySQL:
Sql("USE databaseName");
However, while this will work for MySQL, it will fail for Oracle / MsSql.

1. Oracle:
a) try the following SQL via Sql command:
Sql("alter session set current_schema=AnotherUser");
b) you can also execute the same SQL via the Initialization Command connection string parameter of OracleConnection: http://www.devart.com/dotconnect/oracle/docs/?Devart.Data.Oracle~Devart.Data.Oracle.OracleConnection~ConnectionString.html . The same connection string parameter is available in dotConnect for MySQL.

2. SQL Server:
Tell us the exact text of the error when you are executing Sql("use [database name]"); for SQL Server.
Shalex
Devart Team
 
Posts: 7530
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL