📄 asp实现从sql server导数据到access或excel文件 .htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0054)http://www.51base.com/article/view_article.asp?id=5535 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="NB联盟7.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position
width=773>
<TBODY>
<TR>
<TD class=shadow colSpan=2 height=20 width=262> <A
href="http://www.51base.com/"><IMG border=0
src="NB联盟7.files/logo1.gif"></A> </TD>
<TD align=right width=505>
<P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
<TBODY>
<TR>
<TD class=tdlbr vAlign=top>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome
style="TABLE-LAYOUT: fixed" width="98%">
<TBODY>
<TR>
<TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all"
vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>:
ASP实现从SQL Server导数据到Access或Excel文件 </B></FONT>
<HR noShade SIZE=1>
方法其实很简单:需要在SQL Server连接中嵌套一个access连接,然后逐条
<BR>写入就可以了。
<BR><BR><%set Conn = Server.CreateObject("ADODB.Connection")
<BR>Conn.Open "driver={SQL server};server=mamaco;uid=linner;pwd=123;dat
<BR>abase=linner"
<BR>sql="select * from scjh"
<BR>set rs=conn.execute (sql)%>
<BR><%set Conn1 = Server.CreateObject("ADODB.Connection")
<BR>param = "driver={Microsoft Access Driver (*.mdb)}"
<BR>conn.Open param & ";dbq=" & Server.MapPath("scjh.mdb")
<BR>conn1.execute("delete from scjh")%>
<BR><%do while not rs.eof%>
<BR><%dim ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh
<BR>ktdh=rs("ktdh") <BR>scph=rs("scph")
<BR>scts=rs("scts") <BR>jhqtsj=rs("jhqtsj")
<BR>yhxdsj=rs("yhxdsj") <BR>yxj=rs("yxj")
<BR>rwbh=rs("rwbh") <BR>%>
<BR><%sql1="insert into scjh(ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh) values
<BR><BR><BR><BR>('"& ktdh &"','" & scph & "'," & scts & ",'"&jhqtsj&"','"&yhxdsj&"',"&
<BR><BR><BR><BR> yxj &"," & rwbh &")"
<BR>conn1.execute (sql1)%> <BR><%rs.movenext
<BR>loop <BR>conn1.close <BR>conn.close%>
<BR><%response.redirect "/download/scjh.mdb"%>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
<TBODY>
<TR>
<TD align=middle class=tdt>
<P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -