• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> ASP开发 >> 输出打印 >> 详细内容
 

推荐文章

 
 

热点文章

  • Server.Htmlencode的用法
  • 自己动手,结合javascript和dhtml做一个ubb编辑器
  • ASP中几种分页显示的比较
  • 搜索引擎优化:用ISAPI_Rewrite实现asp的静态化
  • 关于客户端用ASP参生报表
  • Haneng.com的简单留言板制作源程序例子
  • 一些ASP小源程序
  • GB2312转UTF-8
  • asp分页显示详论
  • ASP无组件上传图片的基本方法
  • 关于打印页面的一些经验
  • 统计在线人数、每日访问人数和总人数
 
 

相关文章

  • 动感首页更新实现
  • 完整的站点访问统计系统
  • 对数据库中的记录用上一条下一条显示
  • 对数据库中的记录用上一条下一条显示
  • 不能ASP图像组件来生成图像的ASP计数器程序
  • ASP技术在论坛中的运用
  • ASP环境下邮件列表功能的实现
  • 一个BBS的源代码
  • 如何使用ASP在自己的网站建立投票机制
  • 如何用ASP编写网站统计系统
  • 构建你的网站新闻自动发布系统
  • 制作一个个人搜索引擎(源码)
 
 

百度搜索

 
 

关于客户端用ASP参生报表

  • 阅览次数:
  • 文章来源: 网海之贝
  • 原文作者: 佚名
  • 整理日期: 2006-10-03
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

先贴一篇较简单的用ASP+RDS客户端参生报表
此文希望能进精华篇
下一回贴一篇较复杂的
说明:(若提示ActiveX 元件无法参生 RDS.DataSpace)
IE需设置安全选项
操作:菜单工具->INTERNET选项->安全性->自定义
设置  起始但ActiveX不标示为安全->开启   
<html>
<head>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<title>client use rds produce excel report</title>
<link rel="stylesheet" href="cdutmenu/common.css">
</head>
<body bgColor=skyblue topMargin=5 leftMargin="20" oncontextmenu="return false" rightMargin=0 bottomMargin="0">

<div align="center"><center>        
<table border="1" bgcolor="#ffe4b5" style="HEIGHT: 1px; TOP: 0px" bordercolor="#0000ff">
    <tr>
         <td align="middle" bgcolor="#ffffff" bordercolor="#000080">
         <font color="#000080" size="3">   
         client use rds produce excel report
         </font>
         </td>
    </tr>
</table>
</div>

<form action="long.asp" method="post" name="myform">
<DIV align=left>
<input type="button" value="Query Data"   name="query"  language="vbscript" onclick="fun_excel(1)"  style="HEIGHT: 32px; WIDTH: 90px">
<input type="button" value="Clear Data"   name="Clear"  language="vbscript" onclick="fun_excel(2)"  style="HEIGHT: 32px; WIDTH: 90px">
<input type="button" value="Excel Report" name="report" language="vbscript" onclick="fun_excel(3)"  style="HEIGHT: 32px; WIDTH: 90px">
</div>
<DIV id="adddata"></div>
</form>
</body>
</html>

<script language="vbscript">
sub fun_excel(t)
    Dim rds,rs,df               
    dim  strCn,strSQL,StrRs
    Dim xlApp, xlBook, xlSheet1

'use rds to produce client recordset  
    set rds = CreateObject("RDS.DataSpace")
    Set df = rds.CreateObject("RDSServer.DataFactory","http://server name")
'the connection string to sql server to query database:pubs--->table:jobs
    strCn="DRIVER={SQL Server};SERVER=server name;UID=sa;APP=Microsoft Development Environment;DATABASE=pubs;User Id=sa;PASSWORD=;"
'the query string of sql
    strSQL = "Select top 8 * from jobs order by job_id"
'the recordset
    Set rs = df.Query(strCn, strSQL)
   
    if t=1 then  
       if not rs.eof then
          StrRs="<table border=1><tr><td>job_id</td><td>job_desc</td><td>max_lvl</td><td>min_lvl</td></tr><tr><td>"+ rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") +"</td></tr></table>"   
          adddata.innerHTML=StrRs
          StrRs=""
       else
          msgbox "No data in the table!"  
       end if
    elseif t=2 then      
          StrRs=""
          adddata.innerHTML=StrRs
    elseif t=3 then      
       Set xlApp = CreateObject("EXCEL.APPLICATION")
       Set xlBook = xlApp.Workbooks.Add
       Set xlSheet1 = xlBook.Worksheets(1)
       xlSheet1.cells(1,1).value ="the job  table "
       xlSheet1.range("A1:D1").merge
       xlSheet1.cells(2,1).value = "job_id"
       xlSheet1.cells(2,2).value = "job_desc"
       xlSheet1.cells(2,3).value = "max_lvl"
       xlSheet1.cells(2,4).value = "min_lvl"
       cnt = 3
'adapt to office 97 and 2000
       do while not rs.eof
          xlSheet1.cells(cnt,1).value = rs("job_id")
          xlSheet1.cells(cnt,2).value = rs("job_desc")
          xlSheet1.cells(cnt,3).value = rs("max_lvl")
          xlSheet1.cells(cnt,4).value = rs("min_lvl")
          rs.movenext
          cnt = cint(cnt) + 1
       loop
       xlSheet1.Application.Visible = True
      
'adapt to office 2000 only
        'xlSheet1.Range("A3").CopyFromRecordset rs
        'xlSheet1.Application.Visible = True
    end if
end sub
</script>

    

    关于客户端用ASP参生报表(高级篇)

上回曾贴一篇较简单的用ASP+RDS客户端参生报表
此回贴一篇较复杂的用ASP+RDS+组件客户端参生报表
错误说明:(若提示ActiveX 元件无法参生 RDS.DataSpace)
IE需设置安全选项
操作:菜单工具->INTERNET选项->安全性->自定义
设置:起始但ActiveX不标示为安全->开启   
原理说明:
    客户端直接用RDS产生RecordSet安全性不够,使用了
middle-tier Automation components 后可大大增加安全性!
请看下文:
编写注册元件:
ActiveX Dll project:iacrdsobj.vbp
Class Module name:RsOp

Public Function ReturnRs(strDB As Variant, strSQL As Variant) As ADODB.Recordset
        'Returns an ADODB recordset.
        On Error GoTo ehGetRecordset
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim strConnect As String  
        strConnect = "Provider=SQLOLEDB;Server=server name ;uid=sa;pwd=; Database=" & strDB & ";"
        cn.Open strConnect
        'These are not listed in the typelib.
        rs.CursorLocation = adUseClient
        'Using the Unspecified parameters, an ADO/R recordset is returned.
        rs.Open strSQL, cn, adOpenUnspecified, adLockUnspecified, adCmdUnspecified
        Set ReturnRs = rs
      Exit Function
ehGetRecordset:
        Err.Raise Err.Number, Err.Source, Err.Description
      End Function
然后 MAKE iacrdsobj.dll
若有错,请设置VB菜单PROJECT-REFREENCE
增加 MicroSoft ActiveX Data Object 2.6 Library(当然数字要高一点)

然后 注册iacrdsobj.dll到数据库server(为安全,最好更改数据库uid最好不为sa)!
好,接下来看asp
long1.asp
<html>
<head>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<title>client use rds produce excel report</title>
</head>
<body bgColor=skyblue topMargin=5 leftMargin="20" oncontextmenu="return false" rightMargin=0 bottomMargin="0">

<div align="center"><center>        
<table border="1" bgcolor="#ffe4b5" style="HEIGHT: 1px; TOP: 0px" bordercolor="#0000ff">
    <tr>
         <td align="middle" bgcolor="#ffffff" bordercolor="#000080">
         <font color="#000080" size="3">   
         client use rds produce excel report
         </font>
         </td>
    </tr>
</table>
</div>
<form action="long1.asp" method="post" name="myform">
<DIV align=left>
<input type="button" value="Query Data"   name="query"  language="vbscript" onclick="fun_excel(1)"  style="HEIGHT: 32px; WIDTH: 90px">
<input type="button" value="Clear Data"   name="Clear"  language="vbscript" onclick="fun_excel(2)"  style="HEIGHT: 32px; WIDTH: 90px">
<input type="button" value="Excel Report" name="report" language="vbscript" onclick="fun_excel(3)"  style="HEIGHT: 32px; WIDTH: 90px">
</div>
<DIV id="adddata"></div>
</form>
</body>
</html>
<script language="vbscript">
sub fun_excel(t)
    Dim rds,rs,df,ServerStr               
    dim strSQL,StrRs
    Dim xlApp, xlBook, xlSheet1
    ServerStr="http://Sql Server Name" 'the sql server name of register iacRDSObj.dll
'use rds to produce client recordset  
    set rds = CreateObject("RDS.DataSpace",ServerStr)
    'eg:set rds = CreateObject("RDS.DataSpace","http://iac_fa")  'iac_fa is the LAN sql server name
    'eg:set rds = CreateObject("RDS.DataSpace","http://10.150.254.102") '10.150.254.102 is the LAN sql server IP Address
'the register com
    Set df = rds.CreateObject("iacRDSObj.rsop", ServerStr)
'the query string of sql
    strSQL = "Select top 8 * from jobs order by job_id"
'the recordset
    Set rs = df.ReturnRs("pubs",strSQL)
    if t=1 then  
       if not rs.eof then
          StrRs="<table border=1><tr><td>job_id</td><td>job_desc</td><td>max_lvl</td><td>min_lvl</td></tr><tr><td>"+ rs.GetString(,,"</td><td>","</td></tr><tr><td>"," ") +"</td></tr></table>"   
          adddata.innerHTML=StrRs
          StrRs=""
       else
          msgbox "No data in the table!"  
       end if
    elseif t=2 then      
          StrRs=""
          adddata.innerHTML=StrRs
    elseif t=3 then      
       Set xlApp = CreateObject("EXCEL.APPLICATION")
       Set xlBook = xlApp.Workbooks.Add
       Set xlSheet1 = xlBook.Worksheets(1)
       xlSheet1.cells(1,1).value ="the job  table "
       xlSheet1.range("A1:D1").merge
       xlSheet1.cells(2,1).value = "job_id"
       xlSheet1.cells(2,2).value = "job_desc"
       xlSheet1.cells(2,3).value = "max_lvl"
       xlSheet1.cells(2,4).value = "min_lvl"
       cnt = 3
'adapt to office 97 and 2000
       do while not rs.eof
          xlSheet1.cells(cnt,1).value = rs("job_id")
          xlSheet1.cells(cnt,2).value = rs("job_desc")
          xlSheet1.cells(cnt,3).value = rs("max_lvl")
          xlSheet1.cells(cnt,4).value = rs("min_lvl")
          rs.movenext
          cnt = cint(cnt) + 1
       loop
       xlSheet1.Application.Visible = True
      
'adapt to office 2000 only
        'xlSheet1.Range("A3").CopyFromRecordset rs
        'xlSheet1.Application.Visible = True
    end if
    rs.close
    set rs=nothing
end sub
</script>

       

上一篇:MySQL数据库的导入导出 和 Liunx的权限
下一篇:构建支持Master/Slave读写分离的数据库操作类
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号