asp连接access数据库进行2次操作的问题

来源:百度知道 编辑:UC知道 时间:2024/06/20 09:38:07
access表test字段:year,level,class,eid,equestion,opt1,opt2,opt3,opt4,key
想实现的功能:select top 1 * form test where eid=(select max(eid) from test where year='2008' and level='1' and class='1')选出按年,级别,类型排序中的eid最大值,将max(eid)赋给maxnum
然后插入一条新记录时自动将eid加1, insert into test(year,level,class,eid,equestion,opt1,opt2,opt3,opt4,key) values('2008','1','1',maxnum+1,'123456','111','222','333','444','111')
请问高手如何实现?

insert into test(year,level,class,eid,equestion,opt1,opt2,opt3,opt4,key) select '2008','1','1',maxnum+1,'123456','111','222','333','444','111' from (select max(eid) as maxnum from test where year='2008' and level='1' and class='1') as A

在ACCESS能实现的功能比较少。如果想要实现这样的效果最好是MSSQL ACCESS只能一条一条的执行SQL,
在MSSQL可以像lazy67回答的