1。在向一个数据库中添加记录,要求当id和功能两个数据段的值一样事覆盖,当其  中之一不同时添加在该功能的最后。请各位给个算法,最好有代码。
2。还有一个问题,就是在保存文件时但该目录下有同样的文件就将已有的文件删除。

解决方案 »

  1.   

    使用存储过程实现(MS-SQL):
    create procedure Text
    @ID    int,
    @功能  varchar(20),
    @Other varhcar(50)
    as
    begin
     if exists(select * from Tabel1 where ID=@ID and 功能=@功能)
       update table1 set Other=@other where where ID=@ID and 功能=@功能
     else
       insert into table1(ID,功能,other) values(@ID,@功能,@Other)
    end;然后在代码里调节器用过程就可以了
      

  2.   

    INSERT INTO MYTABLE (FIELD1,FIELD2..) VALUES(VALUE1,VALUE2...)