码迷,mamicode.com
首页 > 其他好文 > 详细

存储过程1

时间:2016-04-18 11:44:28      阅读:113      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!