| 订阅 | 在线投稿
分享
 
 
 

用ASP实现从SQL Server导出数据到Access或Excel文件

2008-08-25 23:36:34 编辑來源:互联网 国际版 评论
 
 
本文为【用ASP实现从SQL Server导出数据到Access或Excel文件】的汉字拼音对照版显示拼音
  qianduanshijianwozaiwangshangfachuguozheyangdewentixianzaiyijingdedaojiejuexianjiangdaimagongxiang

  xiwangduiIntranetMISaihaozheyousuobangzhu

  fangfaqishihenjiandanxuyaozaiSQL Serverlianjiezhongqiantaoyigeaccesslianjieranhouzhutiao

  xierujiukeyile

  <%set Conn = Server.CreateObject("ADODB.Connection")

  Conn.Open "driver={SQL server};server=mamaco;uid=linner;pwd=123;dat

  abase=linner"

  sql="select * from scjh"

  set rs=conn.execute (sql)%>

  <%set Conn1 = Server.CreateObject("ADODB.Connection")

  param = "driver={Microsoft Access Driver (*.mdb)}"

  conn.Open param & ";dbq=" & Server.MapPath("scjh.mdb")

  conn1.execute("delete from scjh")%>

  <%do while not rs.eof%>

  <%dim ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh

  ktdh=rs("ktdh")

  scph=rs("scph")

  scts=rs("scts")

  jhqtsj=rs("jhqtsj")

  yhxdsj=rs("yhxdsj")

  yxj=rs("yxj")

  rwbh=rs("rwbh")

  %>

  <%sql1="insert into scjh(ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh)

  values

  ('"& ktdh &"','" & scph & "'," & scts

  & ",'"&jhqtsj&"','"&yhxdsj&"',"&

  yxj &"," & rwbh &")"

  conn1.execute (sql1)%>

  <%rs.movenext

  loop

  conn1.close

  conn.close%>

  <%response.redirect "/download/scjh.mdb"%>原文
 
 
前段时间,我在网上发出过这样的问题,现在已经得到解决,现将代码共享, 希望对IntranetMIS爱好者有所帮助 方法其实很简单:需要在SQL Server连接中嵌套一个access连接,然后逐条 写入就可以了。 <%set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "driver={SQL server};server=mamaco;uid=linner;pwd=123;dat abase=linner" sql="select * from scjh" set rs=conn.execute (sql)%> <%set Conn1 = Server.CreateObject("ADODB.Connection") param = "driver={Microsoft Access Driver (*.mdb)}" conn.Open param & ";dbq=" & Server.MapPath("scjh.mdb") conn1.execute("delete from scjh")%> <%do while not rs.eof%> <%dim ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh ktdh=rs("ktdh") scph=rs("scph") scts=rs("scts") jhqtsj=rs("jhqtsj") yhxdsj=rs("yhxdsj") yxj=rs("yxj") rwbh=rs("rwbh") %> <%sql1="insert into scjh(ktdh,scph,scts,jhqtsj,yhxdsj,yxj,rwbh) values ('"& ktdh &"','" & scph & "'," & scts & ",'"&jhqtsj&"','"&yhxdsj&"',"& yxj &"," & rwbh &")"  conn1.execute (sql1)%> <%rs.movenext loop conn1.close conn.close%> <%response.redirect "/download/scjh.mdb"%>
󰈣󰈤
 
 
>>返回首页<<
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 
 热帖排行
 
 
王朝网络微信公众号
微信扫码关注本站公众号wangchaonetcn
 
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
©2005- 王朝网络 版权所有