c# - I'm not getting return value of stored procedure. var @id is not supplied.? -


this sql server stored procedure insert data:

alter proc insert_stud1      @name varchar(20),     @mobile int,     @id int output begin      insert stud1 values (@name, @mobile)      set @id = @@identity; end 

corresponding c#

cmd.commandtype = commandtype.storedprocedure;  cmd.parameters.add("@name",sqldbtype.varchar,20); cmd.parameters.add("@mobile",sqldbtype.int); var ret = cmd.parameters.add("@i", sqldbtype.int); cmd.parameters["@name"].value=textbox1.text; cmd.parameters["@mobile"].value=int.parse(textbox2.text);  cmd.commandtext="insert_stud1";  con.open(); cmd.executenonquery(); messagebox.show(ret.value.tostring()); con.close(); 

you send "@i" instead of "@id"


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -