公共方法静态

       public static string connectionString = ConfigurationManager.ConnectionStrings["Connection eStore"].ToString();   public static DataSet ExeQuery_eStore(string Cmd)
        {
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                SqlDataAdapter da = new SqlDataAdapter();
                SqlCommand command = new SqlCommand(Cmd, con);
                con.Open();
                da.SelectCommand = command;
                DataSet ds = new DataSet();
                da.Fill(ds);
                con.Close();
                return ds;
            }
        }

        public static void ExeNonQuery_eStore(string cmd)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = connectionString;
            con.Open();
            SqlCommand com = new SqlCommand();
            com.Connection = con;
            com.CommandType = CommandType.Text;
            com.CommandText = cmd;
            SqlDataReader dr = com.ExecuteReader();
            dr.Close();
            con.Close();
        }

 

posted @ 2020-05-19 14:15  ProZkb  阅读(162)  评论(0编辑  收藏  举报