2014-09-26 2 views

ответ

0

Вы должны использовать метод DataAdapter.Update.
Вы не дали какой-либо образец кода, так что я покажу вам псевдокод для этого процесса ..

' Create the adapter with a select command text to retrieve your records' 
Dim da = new MySqlDataAdapter(selecttext, connection) 
Dim table = new DataTable() 
da.Fill(table) 

' Create a MySqlCommandBuilder to automatically generate the INSERT/UPDATE/DELETE commands' 
Dim builder = new MySqlCommandBuilder(da) 

' add the new rows to the table' 
Dim row = table.NewRow() 
..... 
table.Rows.Add(row) 

' Send the changes to the database' 
' do not call AcceptChanges before the Update' 
' otherwise every row will be in the State Unchanged ' 
' and no changes will be saved to the database' 
da.Update(table) 

Вы должны удалить AcceptChanges позвонить. Этот метод сложный. Он не пытается обновлять базу данных, но используется только для изменения состояния измененной или вставленной строки и удаления удаленных строк из памяти в формате datatable.

Смежные вопросы