代码没有更新

本文关键字:更新 代码 | 更新日期: 2023-09-27 17:50:14

为什么我的代码不能更新?

代码:

    //Create a new Insurance
    Insurance oInsurance = new Insurance();
    oInsurance.Active = true;
    oInsurance.Address1 = txtAddress.Text;
    oInsurance.Address2 = txtAddress.Text;
    oInsurance.Name = txtName.Text;
    oInsurance.City = txtCity.Text;
    oInsurance.BillingProviderAddress = txtNameSubmit.Text;

代码没有更新

要更新记录,必须传递表的主键/唯一键。当你传递其他参数时,你必须传递键列来更新,

oInsurance.PrimaryKey/UniqueColumnName = Value;

最后,当查询将构建时,它将错过其中部分,

update table set columnName=@Value where ID = ?

当尝试更新一条记录时,应该传递一个唯一的值来更新特定的记录或一组记录(有时可能是主键),

update tablename set columnName=@columnvalue where uniquerecordkey = @identifyingkeyvalue