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"
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"