could any one please help me in using the output parameters to retrieve some data from my database to a web form!!
here is a sample code:
stored procedure::
alter proc uid_availabilit y_check
@userid varchar(25),
@tot int output
as
select * from myuserinfo where (myuserinfo.use rid=@userid)
set @tot=@@rowcount
c# code::
(here con is my connection to the database)
OleDbCommand mycmd = new OleDbCommand();
mycmd.CommandTy pe = CommandType.Sto redProcedure;
mycmd.CommandTe xt = "uid_availabili ty_check";
mycmd.Connectio n = con;
OleDbParameter p1 = new OleDbParameter( );
p1 = mycmd.Parameter s.Add("@userid" , OleDbType.VarCh ar);
p1.Value = enteruserid.Tex t;
p1.Direction = ParameterDirect ion.Input;
OleDbParameter p2=new OleDbParameter( );
p2.OleDbType=Ol eDbType.Integer ;
p2.Direction= ParameterDirect ion.Output;
p2=mycmd.Parame ters.Add("@tot" , OleDbType.Integ er);
con.Open();
mycmd.ExecuteNo nQuery();
con.close();
label1.Text = p2.Value.ToStri ng();
i know this is wrong....but dont know how to correct it.
and i know to do this using a data reader, without using output parameter.
so...could any one please help me in correcting this.. and tell me how to use the out parameters.
thank you
here is a sample code:
stored procedure::
alter proc uid_availabilit y_check
@userid varchar(25),
@tot int output
as
select * from myuserinfo where (myuserinfo.use rid=@userid)
set @tot=@@rowcount
c# code::
(here con is my connection to the database)
OleDbCommand mycmd = new OleDbCommand();
mycmd.CommandTy pe = CommandType.Sto redProcedure;
mycmd.CommandTe xt = "uid_availabili ty_check";
mycmd.Connectio n = con;
OleDbParameter p1 = new OleDbParameter( );
p1 = mycmd.Parameter s.Add("@userid" , OleDbType.VarCh ar);
p1.Value = enteruserid.Tex t;
p1.Direction = ParameterDirect ion.Input;
OleDbParameter p2=new OleDbParameter( );
p2.OleDbType=Ol eDbType.Integer ;
p2.Direction= ParameterDirect ion.Output;
p2=mycmd.Parame ters.Add("@tot" , OleDbType.Integ er);
con.Open();
mycmd.ExecuteNo nQuery();
con.close();
label1.Text = p2.Value.ToStri ng();
i know this is wrong....but dont know how to correct it.
and i know to do this using a data reader, without using output parameter.
so...could any one please help me in correcting this.. and tell me how to use the out parameters.
thank you
Comment