如何实现添加多条记录ASP
经测试可以从A.MDB中添加到B.MDB中第一条记录,如何实现添加多条记录呢请行家指点。<%dimSMT_news,SMT_title,tianjia%><%setcon...
经测试可以从A.MDB 中添加到B.MDB中第一条记录,如何实现添加多条记录呢请行家指点。
<% dim SMT_news,SMT_title ,tianjia %>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
%>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("B.mdb")
conn.open connstr
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from SMT_news ",conn,1,3
rs.addnew
rs("SMT_title")=SMT_title
rs("SMT_news")=SMT_news
rs.update
%>
<%
rs.close
set rs=nothing
conn.close
%>
试试 展开
<% dim SMT_news,SMT_title ,tianjia %>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
%>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("B.mdb")
conn.open connstr
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from SMT_news ",conn,1,3
rs.addnew
rs("SMT_title")=SMT_title
rs("SMT_news")=SMT_news
rs.update
%>
<%
rs.close
set rs=nothing
conn.close
%>
试试 展开
2个回答
展开全部
如果俩表的结构一样 建议用复制粘贴
<% dim SMT_news,SMT_title ,tianjia
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
set conn1=server.createobject("adodb.connection")
connstr1="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("B.mdb")
conn1.open connstr1
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
do while not rs.eof
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from SMT_news ",conn1,1,3
rs1.addnew
rs1("SMT_title")=SMT_title
rs1("SMT_news")=SMT_news
rs1.update
rs1.close
set rs1=nothing
rs.movenext
loop
rs.close
set rs=nothing
conn1.close
set conn1=nothing
conn.close
set conn=nothing
%>
<% dim SMT_news,SMT_title ,tianjia
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
set conn1=server.createobject("adodb.connection")
connstr1="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("B.mdb")
conn1.open connstr1
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
do while not rs.eof
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
set rs1=server.createobject("adodb.recordset")
rs1.open "select * from SMT_news ",conn1,1,3
rs1.addnew
rs1("SMT_title")=SMT_title
rs1("SMT_news")=SMT_news
rs1.update
rs1.close
set rs1=nothing
rs.movenext
loop
rs.close
set rs=nothing
conn1.close
set conn1=nothing
conn.close
set conn=nothing
%>
展开全部
使用循环
<% dim SMT_news,SMT_title ,tianjia %>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
%>
<%
set conn2=server.createobject("adodb.connection")
connstr2="Provider=Microsoft.jet.oledb.4.0;data source2="&server.mappath("B.mdb")
conn2.open connstr 2
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
do while not rs.eof
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
%>
<%
set rs2=server.createobject("adodb.recordset")
rs2.open "select * from SMT_news ",conn,1,3
rs2.addnew
rs2("SMT_title")=SMT_title
rs2("SMT_news")=SMT_news
rs2.update
%>
<%
rs.movenext
loop
rs2.close
set rs2=nothing
conn2.close
rs.close
set rs=nothing
conn.close
%>
<% dim SMT_news,SMT_title ,tianjia %>
<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("A.mdb")
conn.open connstr
%>
<%
set conn2=server.createobject("adodb.connection")
connstr2="Provider=Microsoft.jet.oledb.4.0;data source2="&server.mappath("B.mdb")
conn2.open connstr 2
%>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select SMT_title,SMT_news from SMT_news ",conn,1,1
do while not rs.eof
SMT_title= rs("SMT_title")
SMT_news= rs("SMT_news")
%>
<%
set rs2=server.createobject("adodb.recordset")
rs2.open "select * from SMT_news ",conn,1,3
rs2.addnew
rs2("SMT_title")=SMT_title
rs2("SMT_news")=SMT_news
rs2.update
%>
<%
rs.movenext
loop
rs2.close
set rs2=nothing
conn2.close
rs.close
set rs=nothing
conn.close
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询