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

三层架构:Helper层

时间:2020-07-14 18:04:51      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:scalar   comm   use   dap   三层架构   dataset   return   cti   div   

三层架构:Helper层

  public int count(string sql)
       {
           SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;");
           conn.Open();

           SqlCommand cmd = new SqlCommand(sql, conn);

           int num = (int)cmd.ExecuteScalar();
           conn.Close();
           return num;
           
       }
       public int count1(string sql)
       {
           SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;");

           conn.Open();
           SqlCommand cmd = new SqlCommand(sql, conn);
           int i = cmd.ExecuteNonQuery();

           conn.Close();
           return i;

       }
       public DataTable count2(string sql)
       {

           SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DB_class;User ID=sa;Pwd=123;");

           conn.Open();

           SqlCommand cmd = new SqlCommand(sql, conn);

           SqlDataAdapter dr = new SqlDataAdapter(cmd);

          
           DataSet ds = new DataSet();
           dr.Fill(ds, "shopping");

           DataTable dt = ds.Tables["shopping"];
          
           return dt;

       }

 

三层架构:Helper层

标签:scalar   comm   use   dap   三层架构   dataset   return   cti   div   

原文地址:https://www.cnblogs.com/mvpbest/p/13300215.html

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