Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a trigger on even insert for Item table:
C#
create trigger tr_NextIDItem on Item
for insert
as
begin
    DECLARE @lastIDItem varchar(6)
    SET @lastIDItem  = (SELECT TOP 1 IDItem from Item order by IDItem desc)
    UPDATE Item set IDItem = dbo.func_NextIDItem (@lastIDItem,'IT_',6) where IDItem = ''
end

It's worked when i test on SQL query. But it's not work in asp.net MVC.

My code on ItemController:
C#
context.Item.Add(_item);
context.SaveChanges();

How i can make it work now?
Posted
Comments
Kornfeld Eliyahu Peter 7-Jan-15 6:12am    
Maybe IDItem is null and not empty string or it has a value from the code already?
GinCanhViet 7-Jan-15 6:15am    
I make IDItem = 1. It's wrong ?
GinCanhViet 7-Jan-15 6:19am    
Hey, thank you so much :*
I love you :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900