zoukankan      html  css  js  c++  java
  • dbhelper

    public class Helper
        {
            private static string ConnString = ConfigurationManager.ConnectionStrings["app"].ConnectionString;
            public static SqlDataReader GetReader(string sql)
            {
                SqlConnection Conn = new SqlConnection(ConnString);
    
                Conn.Open();
                SqlCommand comm = new SqlCommand(sql, Conn);
                SqlDataReader Reader = comm.ExecuteReader(CommandBehavior.CloseConnection);
                return Reader;
            }
            public static DataSet GetDataSet(string sql)
            {
                DataSet DataSet = new DataSet();
                using (SqlConnection Conn = new SqlConnection(ConnString))
                {
                    Conn.Open();
                    SqlDataAdapter Adapter = new SqlDataAdapter(sql, ConnString);
                    Adapter.Fill(DataSet);
                    Conn.Close();
                    Conn.Dispose();
                }
                return DataSet;
            }
            public static int ExecSql(string sql)
            {
                int i = 0;
                using (SqlConnection Conn = new SqlConnection(ConnString))
                {
                    Conn.Open();
                    SqlCommand comm = new SqlCommand(sql, Conn);
                    i = comm.ExecuteNonQuery();
                    Conn.Close();
                    Conn.Dispose();
                }
                return i;
            }
        }
  • 相关阅读:
    树的直径
    POJ3264 Balanced Lineup
    [mock]10月11日
    POJ1062 昂贵的聘礼
    POJ3295 Tautology
    [topcoder]TopographicalImage
    POJ1753 Flip Game
    [leetcode]Copy List with Random Pointer
    [leetcode]Candy
    [leetcode]Gas Station
  • 原文地址:https://www.cnblogs.com/jiangqiang/p/2850380.html
Copyright © 2011-2022 走看看