Click here to Skip to main content
15,067,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any idea how to make
C#
table = view.ToTable()

without changing the Original RowState??

What I have tried:

I have a table with name table, which is showing records from mysql DB. I'm filtering it with:
C#
view.RowFilter = "Some String";
after filtering:
C#
table = view.ToTable();
try
{
    string myConnection = ConfigurationManager.ConnectionStrings["vizitka"].ToString();
    MySqlConnection connection = new MySqlConnection(myConnection);
    string sQuery = "SELECT " +
                     "msoflioqveknebisklasifikatori.* " +
                     "FROM " +
                     "msoflioqveknebisklasifikatori";
    MySqlDataAdapter myDA = new MySqlDataAdapter(sQuery, connection);
    MySqlCommandBuilder cmb = new MySqlCommandBuilder(myDA);
    myDA.Update(table);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

but DataAdapter makes database changes according to DataRow.RowState property. And unfortunatelly table = view.ToTable() adding rows (old and new) to my dataTable and sets RowState Added instead of RowState = Modified
Posted
Updated 20-Jan-18 11:23am
v2
Comments
Hermann Jung 21-Jan-18 4:20am
   
Why don't use "view.Table" or "view.Cast<DataRowView>().Select(drv => drv.Row).ToArray()" for update?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900