| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 654 人关注过本帖
标题:asp程序出错!
只看楼主 加入收藏
wwm123456789
Rank: 4
等 级:业余侠客
帖 子:63
专家分:204
注 册:2010-4-4
结帖率:92.86%
收藏
 问题点数:0 回复次数:2 
asp程序出错!
我是想利用asp将access查询结果导出到excel文件,出错,请指点,谢谢。代码如下
程序代码:
<!-- #include file = "../common/site.inc" -->
<%
    Dim rsAdministrator
    Set rsAdministrator = cn.Execute("SELECT * FROM Administrator WHERE AdministratorID = '" & Session("AdminID") & "' AND Password = '" & Session("AdminPwd") & "'")
           
    If rsAdministrator.EOF = True And rsAdministrator.BOF = True Then
        Response.Redirect "logon.asp"
    End If
    rsAdministrator.Close
    Set rsAdministrator = Nothing
%>
<%
        Dim rs
    Set rs = cn.Execute("select * from outks")
if not (rs.eof And rs.bof) then
  dim ttxt,file,filepath,writefile
  ttxt="kscj.xls"  '为要写入的文件取个文件名,后缀可以是txt,xls,这里我用csv,这种文件打开也是excel表
  Set file = CreateObject("Scripting.FileSystemObject")
  Application.lock
filepath=Server.MapPath(ttxt) Set Writefile = file.CreateTextFile(filepath,true)
Writefile.WriteLine "学号,姓名,考试分数,考试项目" 
  do while not rs.eof
  Writefile.WriteLine rs("StudentID")&","&rs("Student_Name")&","&rs("ReportScore")&","&rs("Experiment_Name")&"
  rs.movenext
  loop
    Writefile.close
  Application.unlock
  rs.close
  set rs=nothing
  end if   
Response.Write  "生成EXCEL文件成功,点击<a href=""kscj.xls"" target=""_blank"">下载</a>!"
rstData.Close 
set rstData = nothing
Conn.Close
Set Conn = nothing
    Function DataToRsStatic(Conn,strSql)
    Dim RsStatic
    Set DataToRsStatic = Nothing
    If Conn Is Nothing Then
    Exit Function
    End If
        Set RsStatic = CreateObject("ADODB.RecordSet")
        RsStatic.CursorLocation = 3
        RsStatic.Open strSql,Conn,3,3
        If Err.Number <> 0 Then
                Exit Function
        End If
        Set DataToRsStatic = RsStatic
        End Function
%>



[ 本帖最后由 wwm123456789 于 2013-6-15 22:14 编辑 ]
搜索更多相关主题的帖子: asp程序 
2013-06-15 15:08
wwm123456789
Rank: 4
等 级:业余侠客
帖 子:63
专家分:204
注 册:2010-4-4
收藏
得分:0 
怎么没人帮忙看看啊!
2013-06-21 21:15
yinje2005
Rank: 2
等 级:论坛游民
帖 子:79
专家分:14
注 册:2007-6-14
收藏
得分:0 
这段代码不够详细,也没有给出什么错误,这么一段代码不好测试。
2013-06-25 21:53
快速回复:asp程序出错!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019304 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved