• C# 函数4


    //数据库

        public class GF_DA
        {
            /// <summary>
            /// 执行SQL语句 sConnStr 连接字符串,sql执行的sql命令 返回第一行第一列
            /// </summary>
            /// <param name="sConnStr"></param>
            /// <param name="sql"></param>
            /// <returns></returns>
            public static object ExecSQL(string sConnStr, string sql)
            {
                using (SqlConnection conn = new SqlConnection(sConnStr))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        try
                        {
                            conn.Open();
                            cmd.Connection = conn;
                            cmd.CommandText = sql;
                            return cmd.ExecuteScalar();
                        }
                        catch
                        {
                            return null;
                        }
                    }
     
                }
            }
     
            /// <summary>
            /// 执行SQL数组  
            /// </summary>
            /// <param name="sConnStr"></param>
            /// <param name="alSql"></param>
            /// <param name="iLen"></param>
            public static void ExecSQL(string sConnStr, ArrayList alSql, int iLen)
            {
                using (SqlConnection conn = new SqlConnection(sConnStr))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        try
                        {
                            conn.Open();
                            cmd.Connection = conn;
                            for (int i = 0; i < alSql.Count; i++)
                            {
                                cmd.CommandText = alSql[i].ToString();
                                cmd.ExecuteNonQuery();
                                 
                            }
                        }
                        catch
                        {
     
                        }
                    }
     
                }
            }
     
            /// <summary>
            /// 填充数据 返回DataTable
            /// </summary>
            /// <param name="sConnStr"></param>
            /// <param name="sql"></param>
            /// <param name="sTableName"></param>
            /// <returns></returns>
            public static DataTable DataFill(string sConnStr, string sql, string sTableName)
            {
                using (SqlConnection conn = new SqlConnection(sConnStr))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        DataSet ds = new DataSet();
                        try
                        {
                            conn.Open();
                            cmd.Connection = conn;
                            cmd.CommandText = sql;
                            SqlDataAdapter ap = new SqlDataAdapter(cmd);
                            ap.Fill(ds, sTableName);
                            return ds.Tables[0];
                        }
                        catch
                        {
                            return null;
                        }
                    }
     
     
                }
            }
        }
     
     
      /// <summary> 
            /// 加密
            /// </summary> 
            public class DES
            {
                //默认密钥向量
                private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
            }
  • 相关阅读:
    【java虚拟机】垃圾回收机制详解
    【java虚拟机】分代垃圾回收策略的基础概念
    【java虚拟机】内存分配与回收策略
    【java虚拟机】jvm内存模型
    【转】新说Mysql事务隔离级别
    【转】互联网项目中mysql应该选什么事务隔离级别
    有关PHP的字符串知识
    php的查询数据
    php练习题:投票
    php的数据访问
  • 原文地址:https://www.cnblogs.com/liufei88866/p/3478360.html
Copyright © 2020-2023  润新知