0
我使用MS Access作爲我的數據庫,並使用數據集檢索和更新我的WPF應用程序。 數據顯示在datagrid中,沒有問題。 但是,當我嘗試使用以下代碼插入數據時,插入已成功完成,但無法在Access文件中看到新行。從DataTableAdapter插入不反映在MS Access數據庫中!
var add = new AddressBookDataSet();
adc.Fill(add.Address);
var v = add.Address.NewAddressRow();
v.StreetAddress = textBoxStreetAddress.Text;
v.AtPost = textBoxAtPost.Text;
v.Taluka = textBoxTaluka.Text;
v.District = textBoxDistrict.Text;
v.State = textBoxState.Text;
v.Pincode = textBoxPincode.Text;
v.PhoneNumber1 = textBoxContact1.Text;
v.PhoneNumber2 = textBoxContact2.Text;
v.PhoneNumber3 = textBoxContact3.Text;
v.PhoneNumber4 = textBoxContact4.Text;
v.FaxNumber1 = textBoxFax1.Text;
v.FaxNumber2 = textBoxFax2.Text;
add.Address.AddAddressRow(v);
add.Address.AcceptChanges();
//adc.Insert(textBoxStreetAddress.Text, textBoxAtPost.Text, textBoxTaluka.Text, textBoxDistrict.Text, textBoxState.Text, textBoxPincode.Text, textBoxContact1.Text, textBoxContact2.Text, textBoxContact3.Text, textBoxContact4.Text, textBoxFax1.Text, textBoxFax2.Text);
這裏有什麼問題?我檢查了.accdb沒有標記爲只讀! here,1字段v.Id已被省略,因爲Id字段是自動編號! 另外,在創建一個新的行之前,我嘗試了adc.Insert(即TableAdapter.Insert),但它並沒有在DB中更新!
你有插入命令嗎? – JeffO 2011-04-11 13:30:49
是的,我喜歡。 問題已解決,我正在修改源文件夾中的/ bin/debug /目錄中的文件。 – manishKungwani 2011-04-13 08:19:32