dbReader.ReadAll() : Error using Database Schema Reader > 1.6.0.4

Aug 20, 2016 at 8:16 AM
Hi all, I got an error using dbReader.ReadAll() with the new version of Database Schema Reader > 1.6.0.4 (which is the last ok) : I tried 2.0.0.6 and 2.1.01 versions. Now I got the error : Fatal error encountered during command execution : Parameter '@tableName' must be defined

Here is the full info :
\DatabaseSchemaReader\ProviderSchemaReaders\Databases\SqlExecuter.cs
abstract class SqlExecuter
protected void ExecuteDbReader(DbConnection connection)
using (var dr = cmd.ExecuteReader())

SELECT
TRIGGER_SCHEMA AS 'OWNER',
TRIGGER_NAME,
EVENT_OBJECT_TABLE AS 'TABLE_NAME',
ACTION_STATEMENT AS 'TRIGGER_BODY',
EVENT_MANIPULATION AS 'TRIGGERING_EVENT',
ACTION_TIMING AS 'TRIGGER_TYPE'
FROM information_schema.Triggers
WHERE
(EVENT_OBJECT_TABLE = @tableName OR @tableName IS NULL) AND
(TRIGGER_SCHEMA = @schemaOwner OR @schemaOwner IS NULL)

L'exception MySql.Data.MySqlClient.MySqlException s'est produite
HResult=-2147467259
Message=Fatal error encountered during command execution.
Source=MySql.Data
ErrorCode=-2147467259
Number=0
StackTrace:
   à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   à MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   à DatabaseSchemaReader.ProviderSchemaReaders.Databases.SqlExecuter.ExecuteDbReader(DbConnection connection)
InnerException: MySql.Data.MySqlClient.MySqlException
   HResult=-2147467259
   Message=Parameter '@tableName' must be defined.
   Source=MySql.Data
   ErrorCode=-2147467259
   Number=0
   StackTrace:
        à MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName, Int32 parameterIndex)
        à MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet)
        à MySql.Data.MySqlClient.Statement.BindParameters()
        à MySql.Data.MySqlClient.Statement.Execute()
        à MySql.Data.MySqlClient.PreparableStatement.Execute()
        à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   InnerException: [empty]
We can reproduce this error using this code : https://github.com/PatriceDargenton/DBReport
Coordinator
Aug 20, 2016 at 10:19 AM
Confirm that's a bug. I'm lucky enough to use MySql databases without triggers :)
Fix coming shortly.
Aug 20, 2016 at 10:47 AM
Ok, thanks.
Coordinator
Aug 20, 2016 at 11:46 AM
Included in Release v2.1.1, just published
Aug 21, 2016 at 6:40 AM
Yes it works again, but now I found another new bug : all tables of ALL databases are now listed in my dbReport : the database name parameter seems not to be taken account ! If I return back to version 1.6.0.4, It is OK.
Coordinator
Aug 21, 2016 at 7:28 AM
I think it's working as expected. If you specify the database (= schema = owner), you should only see the tables you want:
var dbReader = new DatabaseReader(connectionString, providername);
dbReader.Owner = "sakila"; //specify the database
var schema = dbReader.ReadAll();
It worked before because we used different queries to get the tables. I think before we were using SHOW TABLES, which is restricted to the current database (from the connection string). Other queries weren't restricted, so with a lot of databases you could get way too much information. We sorted it out and discarded the extra data, but that wasn't very efficient.

Now we use Information_Schema, which gives you everything, and we use an explicit parameter to restrict it.

The new way is more efficient, consistent between the different things we're pulling from MySql, and consistent with other databases (Oracle, SqlServer...).
Aug 22, 2016 at 6:32 AM
Ok, everything works fine, thank you.