ColumnMapping problem
Posted by: vincenzofoggia
Date: November 22, 2004 04:42AM

Hi at all

Before sorry for my poor english.
I have problem with binding column of MySqlDataAdapter.
When i binding column manually i must use tha same name of sorceColumn and DatasetColumn.

MySqlConnection Cn = new MySqlConnection(strConnection);

Cn.Open();

DaMySql = new MySqlDataAdapter();

//binding manually
DaMySql.MissingMappingAction = MissingMappingAction.Error;
DataTableMapping table = DaMySql.TableMappings.Add("Articoli","Articoli");
table.ColumnMappings.Add("Id","Key");
table.ColumnMappings.Add("Codice","Code");

string query = "SELECT Id,Codice FROM Articoli";
DataTable dt = new DataTable("Articoli");

DaMySql.SelectCommand = new MySqlCommand(query,Cn);
DaMySql.Fill(dt);
DaMySql.FillSchema(dt,SchemaType.Mapped);

MySqlCommandBuilder cb = new MySqlCommandBuilder(DaMySql);
DaMySql.UpdateCommand = cb.GetUpdateCommand();
DaMySql.InsertCommand = cb.GetInsertCommand();
DaMySql.DeleteCommand = cb.GetDeleteCommand();

DataRow row = dt.NewRow();
row["Key"] = 34;
row["Code"] = "A07";
dt.Rows.Add(row);

DaMySql.Update(dt);


When I call DaMySql.Update(dt); function i receive exception:"The column Codice is not include in table Articoli".Why?
if i binding column with the same name of sourceColumn all is correct.

Thanks in advance

Vincenzo

Options: ReplyQuote


Subject
Written By
Posted
ColumnMapping problem
November 22, 2004 04:42AM
December 29, 2004 03:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.