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_availability_check
@userid varchar(25),
@tot int output
as
select * from myuserinfo where (myuserinfo.userid=@userid)
set @tot=@@rowcount
c# code::
(here con is my connection to the database)
OleDbCommand mycmd = new OleDbCommand();
mycmd.CommandType = CommandType.StoredProcedure;
mycmd.CommandText = "uid_availability_check";
mycmd.Connection = con;
OleDbParameter p1 = new OleDbParameter();
p1 = mycmd.Parameters.Add("@userid" , OleDbType.VarChar);
p1.Value = enteruserid.Text;
p1.Direction = ParameterDirection.Input;
OleDbParameter p2=new OleDbParameter();
p2.OleDbType=OleDbType.Integer;
p2.Direction= ParameterDirection.Output;
p2=mycmd.Parameters.Add("@tot", OleDbType.Integer);
con.Open();
mycmd.ExecuteNonQuery();
con.close();
label1.Text = p2.Value.ToString();
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