Bug #88229 Duplicate Rows in DbMetaDataCollectionNames.DataSourceInformation Collection
Submitted: 26 Oct 2017 8:37 Modified: 30 Jan 2018 7:27
Reporter: Kevin Port Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.10.4 OS:Windows (MySql.Data C#)
Assigned to: CPU Architecture:Any
Tags: DataSourceInformation, DbCommandBuilder, useColumnsForParameterNames

[26 Oct 2017 8:37] Kevin Port
Description:
Hello,

in our c# (.Net 4.5.2) application we want to use the MySqlCommandBuilder to generate our insert,update, deletecommands. 
//builder.GetUpdateCommand(true);
//builder.GetInsertCommand(true);
//builder.GetDeleteCommand(true);

The generated Paremeters and the Command text should contain the real columnames as parameternames(@ID, @Preis,@Description), therefore we use the the method builder.GetUpdateCommand(true); instead of builder.GetUpdateCommand();
//useColumnsForParameterNames True, False = default

But the generated Command has parameternames like @p1, @p2, @p3..

If you take a look at System\Data\Common\DBCommandBuilder.cs, you will find multiple codelines which suggest that if the metadatacollection "DataSourceInformation" contains multiple rows, useColumnsForParameterNames is set to false. 

Please take a look at: private void BuildCache(bool closeConnection, DataRow dataRow, bool useColumnsForParameterNames)

With the following lines you see that the driver returns multiple rows for schemainformation. Why?
int count = con.GetSchema(DbMetaDataCollectionNames.DataSourceInformation).Rows.Count;
var table = con.GetSchema(DbMetaDataCollectionNames.DataSourceInformation)

Yours faithfully,

Kevin Port
rocon Gmbh

How to repeat:
string conS = "Server=192.168.70.115; Port=3306; Database=spiel; Uid=root; Pwd=root";
            string query = "SELECT * FROM `artikel`";

            MySqlConnection con = new MySqlConnection(conS);
            con.Open();
 int count = con.GetSchema(DbMetaDataCollectionNames.DataSourceInformation).Rows.Count;

//count is 2, But Why?
//To use 

 MySqlCommand command = new MySqlCommand(query, con);
 MySqlDataAdapter ad = new MySqlDataAdapter(command);
MySqlCommandBuilder builder = new MySqlCommandBuilder(ad);

//useColumnsForParameterNames = True
//We don't want parameternames like @p1, @p2
//We want parameternames like the real columnnames @ID, @Preis,@Description
var up = builder.GetUpdateCommand(true);

Suggested fix:
Return exactly one row for the metadatacollection "DataSourceInformation"
[6 Nov 2017 7:48] Chiranjeevi Battula
Hello Kevin,

Thank you for the bug report.
Verified this behavior on Visual Studio 2015 and Connector/NET 6.10.4 version.

Thanks,
Chiranjeevi.
[6 Nov 2017 7:48] Chiranjeevi Battula
Screenshot

Attachment: Bug_88229.JPG (image/jpeg, text), 120.85 KiB.

[30 Jan 2018 7:27] Kevin Port
Hello,

but what will happen now?
You verified this as a bug, but when will you release the bugfix?