码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-04-16 10:17:51      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

    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为参数名称

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

标签:

原文地址:http://www.cnblogs.com/MyBeN/p/4431212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!