表A
id  item
a1   b1
a2   b2
a3   b3表B
id  item  name
1    b1   xxx
1    b1   yyy
2    b2   xxx
3    b3   xxx我想要表B里的item跟随表A的item变化,有没有什么办法?页面用asp的,数据库为access,最好给我段代码,谢谢!

解决方案 »

  1.   

    表A
    id  item
    a1  b1
    a2  b2
    a3  b3表B
    id  item  name
    a1    b1  xxx
    a1    b1  yyy
    a2    b2  xxx
    a3    b3  xxx 
    是这样的,就是表A和表B,表A是参照..
    如我调出表A的内容,id  item
    a1  b1
    办里是输入框:
    id  item  name
    a1   b1   xxx希望调同的表A的值能和表B的值对应...如果表A中的序列有变化,依然能对应...
      

  2.   

    如果表A中的序列有变化,依然能对应...
    你是指,表A的ID发生了变化?
      

  3.   

    B表的item引用了A表的item吧B表设置级联更新
      

  4.   

    我不会用ACCESS下面是MS-SQL SERVER的if object_id('tb') is not null drop table tb
    if object_id('ta') is not null drop table ta
    set nocount on 
    go
    create table ta (id int identity(1,1),item varchar(10) primary key )
    insert into ta select 'b1' union all select 'b2' union all select 'b3' 
    go
    create table tb (id int , item varchar(10),constraint FK_tb foreign key (item) references ta(item) on update cascade)
    insert into tb select 1,'b1' union all select 1,'b1' union all select 2, 'b2' union all select 3,'b3'
    go
    select * from ta
    select * from tb
    /*id item
    1 b1
    2 b2
    3 b3id item
    1 b1
    1 b1
    2 b2
    3 b3
    */
    go
    update ta set item='b8' where item='b2'
    go
    select * from ta
    select * from tb
    /*
    id item
    1 b1
    3 b3
    2 b8id item
    1 b1
    1 b1
    2 b8
    3 b3
    */
    set nocount off
      

  5.   


    设计表时,上面工具栏有一个关联的
    点进去
    设置下表A与表B的ITEM字段间的更新关联就可以了
      

  6.   


    但是我B表中会存在多个相同的item哟,会不会出现问题?