Get SQL INSERT OUTPUT value in c# -


in sql stored proc i'm inserting row , hoping return identity int new row, in c# code.

alter procedure the_proc @val_2 varchar(10), @val_3 varchar(10) begin set nocount on insert the_table (field_2, field_3)   output inserted.field_1   values (@val_2, @val_3) end 

in c# i'm using linq fuzzy on how retrieve output value. tried including output parameter in sql proc declaration, couldn't working either (exceptions complaining not being supplied in call). closest i've gotten in walking db.designer.cs code, iexecuteresult result returnvalue contains 0 (not correct) inspecting contained results view (result.returnvalue results view) have outputed value.

key = (int)(db.theproc(val2,val3).returnvalue); 

key coming 0. want identity int value insert.

output inserted.*  

is same thing doing select. isn't going show output parameter rather come result set.

btw, returnvalue should 0 seeing in case.

you'll need change linq statement capture result set.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -