Ejemplo n.º 1
0
        /// <summary>
        /// 更新表中新数据
        /// </summary>
        /// <param name="TableName"></param>
        /// <param name="ColumnName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public static int UpdateNewDataToTable(String TableName, String[] ColumnName, Object[] Value, String KeyColumnName, Object KeyValue)
        {
            //sql生成
            UpdateDBCommandBuilder sql = new UpdateDBCommandBuilder();

            sql.TableName = TableName;
            sql.AddUpdateColumn(ColumnName, Value);
            sql.AddWhere(WhereRelation.None, KeyColumnName, DatabaseMaster.CommandComparison.Equals, KeyValue);

            //数据库连接
            DatabaseInterface database = DBFactory.CreateDatabase(DatabaseInit.DefaultDatabase, DatabaseInit.ConnectName, DatabaseInit.EncryptType);

            database.Open();
            int result = database.ExecueCommand(sql.BuildCommand(), DatabaseInit.WaitTimeout);

            database.Close();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新表中新数据
        /// </summary>
        /// <param name="TableName"></param>
        /// <param name="ColumnName"></param>
        /// <param name="Value"></param>
        /// <returns></returns>
        public static int UpdateNewDataToTable(String TableName, String[] ColumnName, Object[] Value, String[] KeyColumnName, DatabaseMaster.CommandComparison[] comparison, Object[] KeyValue)
        {
            //sql生成
            UpdateDBCommandBuilder sql = new UpdateDBCommandBuilder();

            sql.TableName = TableName;
            sql.AddUpdateColumn(ColumnName, Value);

            for (int i = 0; i < KeyColumnName.Length; i++)
            {
                sql.AddWhere(WhereRelation.And, KeyColumnName[i], (DatabaseMaster.CommandComparison)comparison[i], KeyValue[i]);
            }


            //数据库连接
            DatabaseInterface database = DBFactory.CreateDatabase(DatabaseInit.DefaultDatabase, DatabaseInit.ConnectName, DatabaseInit.EncryptType);

            database.Open();
            int result = database.ExecueCommand(sql.BuildCommand(), DatabaseInit.WaitTimeout);

            database.Close();

            return(result);
        }