Fork me on GitHub
asp.net 调用sql存储过程

public DataSet Bkklist(Dush.common.booklist bkl)
        {
            SqlConnection stcon = new SqlConnection(Dush.dataaccess.conn.sqlconn);
            SqlCommand cmd = new SqlCommand("GetCategories", stcon); //存储过程名GetCategories
            cmd.CommandType = CommandType.StoredProcedure; //声明调用存储过程


            cmd.Parameters.Add(new SqlParameter("CategoriyId",SqlDbType.Int ));

            cmd.Parameters["CategoriyId"].Value = bkl.CategoriyId1;

            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            try
            {
                sda.Fill(ds);
                return ds;
            }
            catch (System.Exception E)
            {
                throw new System .Exception (E.Message);
            }
           

        }

posted on 2010-06-23 17:52  HackerVirus  阅读(174)  评论(0编辑  收藏  举报