请教一个ADO.NET 访问数据库的问题
下面程序段抄自微软的例子,有几个问题不明白,恳请赐教。
private SqlDataAdapter dsCommand;
public bool InsertCustomer(CustomerData customer)
{
if ( dsCommand == null )
{
throw new System.ObjectDisposedException( GetType().FullName );
}
//问题1:dsCommand不是会自动生成Command对象吗,为什么需要调用//下面这一句生成Command对象
dsCommand.InsertCommand = GetInsertCommand();
dsCommand.Update(customer, CustomerData.CUSTOMERS_TABLE);
//
// Check for table errors to see if the update failed.
//
if ( customer.HasErrors )
{
customer.Tables[CustomerData.CUSTOMERS_TABLE].GetErrors()[0].ClearErrors();
return false;
}
else
{
customer.AcceptChanges();//既然customer是按值传递的,这一句对调用者有何用?
return true;
}
}