日期:2014-05-17 浏览次数:21051 次
lid=request("id") sql="insert into table1(计划内容,完成节点,是否完成) select 计划内容,完成节点,是否完成 from table1 where id=cint('"&lid&"')" '复制一条记录到数据库里 set rs=server.createobject("adodb.recordset") rs.open sql,connstr,1,3 rs("完成节点")=time1 rs.update newid=rs("id") '得到复制记录的id(不知道是不是这样获得) rs.close sql1="insert into table2(f_id,计划内容,完成节点,是否完成) select f_id,计划内容,完成节点,是否完成 from table2 where f_id=cint('"&lid&"')" set rs1=server.createobject("adodb.recordset") rs1.open sql1,connstr,1,3 rs1("f_id")=newid rs1("完成节点")=time2 rs1.update rs1.close
create proc addnewfromold @oldid int as begin insert into table1(col1,col2) select col1,col2 from table1 where id=@oldid declare @newid int set @newid=@@identity insert into table2(f_id,col3,col4) select @newid,col3,col4 from tabl2 where f_id=@oldid end
------解决方案--------------------
<% lid = Trim(request("id")) Set conn = CreateObject("ADODB.Connection") conn.Open connstr sql = "select 计划内容,完成节点,是否完成 from table1 where id=" & lid Set rs = CreateObject("ADODB.RecordSet") rs.cursorLocation = 3 rs.open sql,conn,1,1 Set rs.activeConnection = Nothing If Not (rs.EOF And rs.BOF) Then plan = Trim(rs("计划内容").Value) time1 = DateAdd("m", 1, CDate(rs("完成节点").Value)) over = rs("是否完成").Value End If rs.close Set rs = Nothing sql = "SELECT * FROM table1 WHERE 1=0" Set rs = CreateObject("ADODB.RecordSet") rs.cursorLocation = 3 rs.open sql,conn,1,3 rs.AddNew rs("计划内容").Value = plan rs("完成节点").Value = time1 rs("是否完成").Value = over iBookmark = rs.Bookmark rs.Update rs.Bookmark = iBookmark newid = rs("id").Value rs.Close Set rs = Nothing sql = "Select 计划内容,完成节点,是否完成 From table2 where f_id=" & lid sql1 = "Select * From table2 where 1=0" Set rs = CreateObject("ADODB.RecordSet") rs.cursorLocation = 3 Set rs1 = CreateObject("ADODB.RecordSet") rs1.cursorLocation = 3 rs.open sql,conn,1,1 Set rs.activeConnection = Nothing rs1.open sql1,conn,1,4 '批处理 Do While Not rs.EOF r