To call the procedure, it need the followng steps
Open the connection of database.
Open the commander, at the same time, we must set the command type be storeprocedure.
Of course, opening the command object, we must supply two arguments, one is the procedure name, and another is the connection name.
3. Add arguments that the procedure needs for the CMD object.
Eg.
Using system. Data. sqlclient;
Public sqldatareader proceduretest ()
{
// Step 1: open connection;
Sqlconnection conn = new sqlconnection ();
Conn. connectionstring = "data sousrce = servername; user id = sa; Pwd = password; initial catalog = Database Name ";
Conn. open ();
// Step 2: set command object;
Sqlcommand cmd = new sqlcommand ("procedure_name", Conn );
Cmd. commandtype = commandtype. storedprocedure;
// Step 3: Set parameter of procedure for cmd object;
Sqlparameter param1 = new sqlparamter ("@ param1_of_procedure", sqldbtype. varchar );
Cmd. Parameter. Add (param1 );
// Step 4; execute cmd;
Sqldatareader RD;
RD = cmd. executequery ();
Return RD;
// Finished;
}