如何更新ID相同且自动递增的已保存数据 [英] how to update saved data whose id is same and auto incremented

查看:76
本文介绍了如何更新ID相同且自动递增的已保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

try
        {
            //objBll.Consignorid =  txtCnsgnrID.Text;
            objBll.ConsignorFname = txtCnsgnrFname.Text;
            objBll.ConsignorLname = txtCnsgnrLname.Text;
            objBll.ConsignorComanyName = txtCnsgnComName.Text;
            objBll.ConsignorAddress = txtCnsgnrAddress.Text;
            objBll.ConsignorLandlineNo = txtCnsgnrLNo.Text;
            objBll.ConsignorPNo = txtCnsgnrPhNo.Text;
            objBll.ConsignorEmail = txtconrEmail.Text;

            objBll.Update("Consignor", "spUpdateConsignor");
            Response.Write("<script>alert('Data Save Successfully')</script>");
            MessageBox.Show("Update success");

            clearConsignorInputText();

        }
        catch (Exception ex)
        {
            MessageBox.Show("Err in private void UpdateConsigner() :" + ex.Message);
        }

推荐答案

如果要更新ID相同的记录,则只需使用和更新ID上的查询即可.
Update table set ... where id = @id.

如果必须更新一条新记录(即刚刚插入的一条记录),则可以使用@@Identity获取最新的 ^ ].
If you are updating a record where the id is the same, you can simply use and update query on the id.
Update table set ... where id = @id.

If you have to update a new record i.e. one that has just been inserted, you can use @@Identity to get the latest column[^].


这篇关于如何更新ID相同且自动递增的已保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆