我有下面的代碼(根據guide)應該插入一個記錄到我的強類型數據集,並依次我的數據庫。但是,記錄不會輸入到數據庫中,但會正確輸入到數據集中。我錯過了一個命令?強類型數據集Adapter.Update不插入行
using (Dataset1TableAdapters.AddressTableAdapter addressAdapter = new Dataset1TableAdapters.AddressTableAdapter())
{
using (Dataset1.AddressDataTable addresses = new Dataset1.AddressDataTable())
{
// Create a new address.
Dataset1.AddressRow address = addresses.NewAddressRow();
// Set some data.
address.Address1 = "test1";
address.Address2 = "test2";
address.Address3 = "test3";
address.UserID = 1;
// Add new address to address table.
addresses.AddAddressRow(address);
// Update the database with all the changes.
addressAdapter.Update(addresses);
}
}
乾杯, 保羅。
嗨。連接對象是正確的。我可以毫無問題地選擇數據庫中的數據。 – paulio 2009-05-29 20:44:00