首页 > 其他 > 详细

存储过程1

时间:2016-04-18 11:42:49      阅读:165      评论:0      收藏:0      [点我收藏+]
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();
                
            }

  

存储过程1

原文:http://www.cnblogs.com/mengluo/p/5403549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!