ado.net 调用带参数的存储过程

    String connString = "Data Source = localhost; Initial Catalog = hkjc;User ID = sa;Pwd = 123";
            SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            SqlCommand cmd = new SqlCommand("GetManagement", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@management", SqlDbType.VarChar, 50).Value = managementname;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt=new DataTable();
            sda.Fill(dt);
            cmd.Dispose();
            cmd.Clone();
            conn.Dispose();
            conn.Close();
            return dt;

 

注:GetManagement为存储过程名称  @management为参数名称

posted on 2015-04-16 10:06  MyBeN  阅读(1228)  评论(0编辑  收藏  举报

导航