Friday, January 7, 2011

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

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);

No comments:

Post a Comment