sql server - stored procedure with out parameter -


i have stored procedure follows:

 alter procedure [dbo].[sp_checkemailavailability]  -- add  parameters stored procedure here ( @email varchar(50)=null,  @count int output   ) begin          -- set nocount on added prevent result sets     -- interfering select statements.  set nocount on;       -- insert statements procedure here          select @count=count(*) dbo.tx_userpersonaldetails s_email=@email        end 

i have following code in aspx.cs page:-

sqlcommand cmd = new sqlcommand("[dbo].[sp_checkemailavailability]", objcon);         int result = 0;          try         {             cmd.commandtype = commandtype.storedprocedure;             sqlparameter parm = new sqlparameter("@email", sqldbtype.varchar);             parm.value = txtusername.text.tostring();             parm.direction = parameterdirection.input;             cmd.parameters.add(parm);              sqlparameter parm1 = new sqlparameter("@count", sqldbtype.int);            // parm1.value = txtusername.text.tostring();             parm.direction = parameterdirection.output;             cmd.parameters.add(parm1);              cmd.connection.open();            result=cmd.executenonquery();               if (result>0)             {                 lblavailtext.text = "email id in use";                }             else             {                 lblavailtext.text = "email id available";             }         }         catch (sqlexception sql)         {          }                 {             cmd.connection.close();          } 

when run code , getting error :-

the formal parameter "@email" not declared output parameter, actual parameter passed in requested output.

please me it.

change

parm.direction = parameterdirection.output; 

to

parm1.direction = parameterdirection.output; 

you setting wrong sqlparam.

parm used @email param, correctly specified input, when create parm1, dont set direction, set parm's direction.

that why should use naming conventions.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -