[英]C# object unique
在我的asp.net Web應用程序中,我正在使用對象將信息添加到數據庫中,如下所示
Employee emp1 = new Employee()
emp1.name = "something"
emp1.age = some age
InsertEmployee(emp)
此代碼可以正常工作。 但是,如果有多個用戶試圖插入員工數據,則數據會變得混亂。
然后,用戶打電話說:“我輸入的年齡與為員工XXX顯示的年齡不同。
如何解決呢? 什么是使對象唯一的好方法?
謝謝....
您可以使用Guid類型使對象唯一。 emp1.Guid = Guid.NewGuid();
User then calls up and says , "The age I entered is different from what it is showing for employee XXX.
您如何更新用戶結果?
How to fix this ? Whats the good method to make the object unique ?.
您需要在數據庫中添加主鍵。 然后針對該主鍵執行所有數據庫操作。 您可以在此處閱讀有關SQL密鑰的信息 。
update yourTable
SET
YourColumnName = YourValue
Where
tableId = Idofthisemployee
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.