2016-05-17 37 views
0

我在.NET中創建了一個簡單的連接到SQL Server表的DataSet。SQL Server和DataSet

我嘗試在表中創建新行,但我不認爲在表 任何改變(在Server Explorer -> right click on the tablbe -> View Table Data

我的代碼是這樣的:

public bool CreateCustomer(Customer customer) 
{ 

    var r = _BDSet.Customer.NewCustomerRow(); 

    r.CustomerId = 0; 
    r.Name = "idan"; 
    r.CustomerDetailsId = 7; 
    _BDSet.Customer.AddCustomerRow(r); 

    _customerAdptr.Fill(_BDSet.Customer); 
    _customerAdptr.Update(_BDSet.Customer); 

    return true; 
} 
+0

只是瘋狂的猜測:因爲你更新之前填寫DataTable,你會失去所有的更改。 – gsharp

+0

'_customerAdptr.Fill(_BDSet.Customer);'扔掉你所有的addRow。可能你不需要這條線,因爲_DBSet已經填滿了。 –

回答

0

嘗試添加該行前return true;

_customerAdptr.AcceptChanges();