DataAdapter.Update() does not Update the Database

后端 未结 9 2024
庸人自扰
庸人自扰 2020-12-16 16:10

I\'m sure there is an extremely simple reason that this one line isn\'t working, but it has evaded for the past week, so I\'m hoping someone else will notice my fault.

9条回答
  •  青春惊慌失措
    2020-12-16 17:12

    Adding AcceptChangesDuringUpdate before Update works for me, example :

    foreach (string tableName in tableNames)
            {             
                da = new SqlDataAdapter("SELECT * FROM " + tableName, cn);
                cb = new SqlCommandBuilder(da); //initialise the update, insert and delete commands of da
                da.AcceptChangesDuringUpdate = true;
                da.Update(myDataSet, tableName);               
            }
    

提交回复
热议问题