存储过程1

drop procedure if exists teach.num_from_student;
create procedure teach.student_a(in dept_name varchar(20),out count_num int)
begin
select count(*) into count_num from t_student where stu_dept=dept_name;
end ;
 using (MySqlConnection conn = new MySqlConnection("server = localhost;User Id=root;password=;database=teach"))
            {

                MySqlCommand cmd = new MySqlCommand("student_a", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter year = new MySqlParameter("dept_name", MySqlDbType.VarChar,20);
                year.Direction = ParameterDirection.Input;
                year.Value =this.comboBox1.Text;
                cmd.Parameters.Add(year);
                 MySqlParameter num = new MySqlParameter("count_num", MySqlDbType.Int16);
                num.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(num);
                conn.Open();
                cmd.ExecuteNonQuery();
                this.label1.Text = num.Value.ToString();
                
            }

  

转载于:https://www.cnblogs.com/mengluo/p/5403549.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值