How to call SP ( stored procedure ) in c# ?

By Super Man

How you can call a stored procedure from the c# code.

     SqlConnection conn=new SqlConnection("connection string here");

     SqlCommand cmd=new SqlCommand();
    
     cmd.Connection = conn;
     cmd.CommandText = "StoredProcedure_Name_here";
     cmd.CommandType = CommandType.StoredProcedure;
     SqlDataAdapter DataAdapterHome = new SqlDataAdapter(cmd);
     DataSet ds= new DataSet();
    
      DataAdapterHome.Fill (ds);

How to call SP ( stored procedure ) in c# ?  (1642 Views)