| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6456 人关注过本帖
标题:求助,Microsoft VBScript 运行时错误 '800a01b6'
只看楼主 加入收藏
陆悠然自得
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-2-1
结帖率:100%
收藏
已结贴  问题点数:5 回复次数:1 
求助,Microsoft VBScript 运行时错误 '800a01b6'
Microsoft VBScript 运行时错误 '800a01b6'

对象不支持此属性或方法: 'session.CodePage'

\admin\stulist2.asp, line 11
以下是代码:
<!--#include file="dataconn.asp"-->
<%
if session("admintype")<>"999" then
response.write "<br><br>对不起,您没有权限使用导入excel的权限!"
response.end
end if
'在线将EXCEL表格数据导入ACCESS
'作者:SCI)_OruA

Response.Buffer = True
Server.ScriptTimeOut = 9999
session.CodePage=936                红色的这行应该是11行吧
dim subjectcjarray(20)
dim sql,rstable,rs,upfile
dim rsfield,rsmdb,rsxls

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="images/Style.css" rel="stylesheet" type="text/css">
<title>EXCEL&gt;ACCESS</title>
<script language="javascript" src="ShowProcessBar.js"></script>
<style type="text/css">
<!--
td {
        font-size: 9pt;
        color: #333333;
        background-color:#ffffff;
        height:20px;
}
body {
        font-size: 9pt;
        color: #333333;
}
.title {
    color:#FFFFFF;
    text-align:center;
    font-size:10pt;
    background-color: #A3B2CC;
}
table {
        background-color:#999999;
}
#uploading {
        display:none;
}
.t_td{
        height:16px;
}
.word{
        color:#ff0000;
        font-weight: bold;
}
.border{
border:1px solid #999999;
color:#000000;
}
.STYLE2 {
    color: #006699;
    font-weight: bold;
}
.STYLE4 {color: #FF0000}
.STYLE5 {color: #CC0000}
-->
</style>
<script>
function uploadstart(){
        if (document.all("file").value==""){
                alert("请选择上传文件");
                return;
        }
        document.all("uploading").style.display="inline";
        document.all("upload").style.display="none";
        document.all("pathtable").style.display="none";
        document.all("fileform").submit();
}
</script>
</head>
<body>
<center>
  <p>
    <%
function HTMLEncode(fString)        
        fString = replace(fString, ">", "&gt;")
        fString = replace(fString, "<", "&lt;")
    fString=  replace(fString, """", "&quot;")
        fString = replace(fstring,"\","\\")
        fString = Replace(fString, CHR(13), "&nbsp;")
        HTMLEncode = fString
end function
'显示错误信息
sub showerr(message)
        response.write "<script>alert("""&HTMLEncode(message)
&""");window.location='stulist2.asp';</script>"
        response.end
end sub
'-----上传文件
if request("action")="upfile" then
        Server.ScriptTimeOut=999999
        dim upload,serverpath,errstr,path,savefilename
        set upload=new UpFile_Class
        path=Request.ServerVariables("PATH_info")
        serverpath=server.MapPath(path)
        serverpath=upload.getfilepath(serverPath)
        path= Left(path,InStrRev(path, "\"))
        upload.GetData(102400000)
        upload.AllowExt="xls;txt;"
        if upload.isErr then
                        select case upload.iserr
                        case 1
                          errstr="请选择上传文件"
                        case 2
                          errstr="上传的文件超出限制,最大10M"                        
                    end select
                        session("xls_path")=""
                        showerr errstr
                else
                        upload.SaveToFile "file",serverpath&upload.file("file").filename
                        if upload.isErr then
                                if upload.isErr=3 then
                                        errstr="只允许上传XLS文件"
                                  else
                                          errstr="上传中遇到未知错误"
                                end if        
                                session("xls_path")=""
                                showerr errstr
                         else
                                 session("xls_path")=path&upload.file("file").filename
                                 upsucess=session("xls_path")
                                response.Redirect
("stulist2.asp?info='"&upsucess&"'")
                        end if
        end if
end if
if request("action")="ready" then
dim FileName
FileName=session("xls_path")  '取得文件名,来自项目经理的指定,路径固定在某个虚拟路径中
set exlconn=CreateObject("ADODB.connection")
exlconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath(""&FileName&"")  
&";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
set rs=createobject("ADODB.recordset")
on error resume next
rs.Open "Select * From [stucj$]",exlconn, 2, 2
if err then
response.write "<br><br>对不起,你还没有把EXCEL默认表名sheet1改为stucj,请更改后再进入导入。
"
response.write "<a href=""stulist.asp"">返回</a>"
response.end
end if
if rs.eof then
 response.write "Excel表中无纪录!<br>"
 response.write "<a href=""stulist.asp"">返回</a>"
 response.end
else
  Set RsDB = Server.CreateObject("ADODB.Recordset")
  sqldel="delete from tempcj"
  conn.execute(sqldel)
  conn.execute("ALTER TABLE tempcj ALTER COLUMN id COUNTER (1, 1)")
   set rsdb=conn.execute("Select id,subjectname from subjectks where testname='"&session
("testname")&"'")
  strsubject=""
  do while not rsdb.eof
  subject=rsdb("subjectname").value
  strsubject=strsubject&subject&","
  rsdb.movenext
  loop
  set rsdb=nothing
  strsubject=left(strsubject,len(strsubject)-1)
  dimsubject=split(strsubject,",")
  kms=ubound(dimsubject)
 i=0
 do while not  rs.eof '利用循环读出数据
 stuidh=rs("学号").value
 stuname=rs("姓名").value
 ''''''''''''neshcy make 修改''''''''''''
 stusr=rs("生日").value
 ''''''''''''neshcy make 修改''''''''''''
 stunj=rs("年级").value
 stubj=rs("班级").value
 subjectfs=""
 for j=0 to kms
 tempcj=trim(rs(dimsubject(j)))
if err then
response.write "<br><br>对不起,EXCEL模板中的第一行数据项没与要求的一致,请更改后再进入导入
。"
response.write "<a href=""stulist.asp"">返回</a>"
response.end
end if
 if isnull(tempcj) then
 tempcj="null"
 end if
 subjectfs=subjectfs&"'"&tempcj&"'"&","
 next
 subjectfs=left(subjectfs,len(subjectfs)-1)
  ''''''''''''neshcy make 修改''''''''''''
 sql="insert into tempcj(stuidh,stuname,生日,nj,bj,"&strsubject&") values
('"&stuidh&"','"&stuname&"','"&stusr&"','"&stunj&"','"&stubj&"',"&subjectfs&")"
  ''''''''''''neshcy make 修改''''''''''''
 response.write "<script>alert("""&sql&""");</script>"
 conn.execute(sql)
 i=i+1
 rs.movenext
 loop
 response.Redirect("stulist2.asp?info1='"&i&"'")
 end if
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>
    <br />
    <a href="stulist.asp">返回</a><br />
  </p>
  <table width="90%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td align="left"><p><span class="STYLE2">
          当前考试名称:
                <%response.write session("testname")%>
                <br />
          <br />
      </span><strong><span class="STYLE2">EXCEL模板制作要求:</span><br />
      请在EXCEL表中第一行依次录入 <span class="STYLE5">学号 姓名 年级 班级&nbsp;
      <%
      sql="select subjectname from subjectks where testname='"&session("testname")&"'"
      'response.write sql
      set rss=conn.execute(sql)
      do while not rss.eof
      response.write rss("subjectname")&"&nbsp;"
      rss.movenext
      loop      
      rss.close
      set rss=nothing
      %></span> 并把EXCEL默认表名sheet1更改为stucj。<span class="STYLE4"> <br />
      模板样表:<a href="up/stucjnullexcel.xls">EXCEL表样(仅供参考)
</a></span></strong></p></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <div id="upload">
    <table width="400" border="0" cellpadding="2" cellspacing="1">
  <tr>
    <td align="left" class="title">第一步:上传EXCEL文件</td>
  </tr>
  <form action="stulist2.asp?action=upfile" method="post" id="fileform"  
enctype="multipart/form-data" name="fileform">
  <tr>
    <td align="center"><input type="file" name="file" />
    <input name="upstart" type="button" id="upstart" value="上传" onclick="uploadstart
();"/></td>
  </tr>
  </form>
</table>
</div>
<div id="uploading">
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="middle" class="title" style="height:40px;">上传中...请稍候</td>
  </tr>
</table>
</div>
<br />
<div id=pathtable>
<form action="stulist2.asp?action=ready" method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td align="left" class="title">第二步:开始数据导入
      <input name="xls_path" type="hidden" id="xls_path" value="<%=session("xls_path")%>"  
/></td>
    </tr>
  <tr>
    <td align="center">
    <%if request.querystring("info")<>"" then response.write "上传成功,请执行数据导入!
"
    if request.querystring("info1")<>"" then response.write "<FONT color=#ff0000>成功导
入数据"&request.querystring("info1")&"条!</font>"%></td>
  </tr>
  <tr>
    <td align="center"><input type="submit" name="Submit" value="数据导入" /></td>
    </tr>
</table>
</form>
<p>第三步:<a href="stulist3.asp?testname=<%=session("testname")%>" isshowprocessbar="true">
进行数据转置并汇总排名</a></p>
</div>

</center>
</body>
</html>
<%
'以下为无惧上传类,非原创
'文件上传类,无惧上传类 V2.2,作者:梁无惧
Class UpFile_Class

Dim Form,File
Dim AllowExt_        '允许上传类型(白名单)
Dim NoAllowExt_        '不允许上传类型(黑名单)
Dim IsDebug_ '是否显示出错信息
Private        oUpFileStream        '上传的数据流
Private isErr_                '错误的代码,0或true表示无错
Private ErrMessage_        '错误的字符串信息
Private isGetData_        '指示是否已执行过GETDATA过程

'------------------------------------------------------------------
'类的属性
Public Property Get Version
        Version="无惧上传类 Version V2.0"
End Property

Public Property Get isErr                '错误的代码,0或true表示无错
        isErr=isErr_
End Property

Public Property Get ErrMessage                '错误的字符串信息
        ErrMessage=ErrMessage_
End Property

Public Property Get AllowExt                '允许上传类型(白名单)
        AllowExt=AllowExt_
End Property

Public Property Let AllowExt(Value)        '允许上传类型(白名单)
        AllowExt_=LCase(Value)
End Property

Public Property Get NoAllowExt                '不允许上传类型(黑名单)
        NoAllowExt=NoAllowExt_
End Property

Public Property Let NoAllowExt(Value)        '不允许上传类型(黑名单)
        NoAllowExt_=LCase(Value)
End Property

Public Property Let IsDebug(Value)        '是否设置为调试模式
        IsDebug_=Value
End Property


'----------------------------------------------------------------
'类实现代码

'初始化类
Private Sub Class_Initialize
        isErr_ = 0
        NoAllowExt=""                '黑名单,可以在这里预设不可上传的文件类型,以文件的后缀名
来判断,不分大小写,每个每缀名用;号分开,如果黑名单为空,则判断白名单
        NoAllowExt=LCase(NoAllowExt)
        AllowExt=""                '白名单,可以在这里预设可上传的文件类型,以文件的后缀名来判
断,不分大小写,每个后缀名用;号分开
        AllowExt=LCase(AllowExt)
        isGetData_=false
End Sub

'类结束
Private Sub Class_Terminate        
        on error Resume Next
        '清除变量及对像
        Form.RemoveAll
        Set Form = Nothing
        File.RemoveAll
        Set File = Nothing
        oUpFileStream.Close
        Set oUpFileStream = Nothing
        if Err.number<>0 then OutErr("清除类时发生错误!")
End Sub

'分析上传的数据
Public Sub GetData (MaxSize)
         '定义变量
        on error Resume Next
        if isGetData_=false then
                Dim  
RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
                Dim sFormValue,sFileName
                Dim iFindStart,iFindEnd
                Dim iFormStart,iFormEnd,sFormName
                '代码开始
                If Request.TotalBytes < 1 Then        '如果没有数据上传
                        isErr_ = 1
                        ErrMessage_="没有数据上传,这是因为直接提交网址所产生的错误!"
                        OutErr("没有数据上传,这是因为直接提交网址所产生的错误!!")
                        Exit Sub
                End If
                If MaxSize > 0 Then '如果限制大小
                        If Request.TotalBytes > MaxSize Then
                        isErr_ = 2        '如果上传的数据超出限制大小
                        ErrMessage_="上传的数据超出限制大小!"
                        OutErr("上传的数据超出限制大小!")
                        Exit Sub
                        End If
                End If
                Set Form = Server.CreateObject ("scripting.Dictionary")
                = 1
                Set File = Server.CreateObject ("scripting.Dictionary")
                = 1
                Set tStream = Server.CreateObject ("ADODB.Stream")
                Set oUpFileStream = Server.CreateObject ("ADODB.Stream")
                if Err.number<>0 then OutErr("创建流对象(ADODB.STREAM)时出错,可能系统不支持
或没有开通该组件")
                oUpFileStream.Type = 1
                oUpFileStream.Mode = 3
                oUpFileStream.Open
                oUpFileStream.Write Request.BinaryRead (Request.TotalBytes)
                oUpFileStream.Position = 0
                RequestBinDate = oUpFileStream.Read
                iFormEnd = oUpFileStream.Size
                bCrLf = ChrB (13) & ChrB (10)
                '取得每个项目之间的分隔符
                sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1)
                iStart = LenB(sSpace)
                iFormStart = iStart+2
                '分解项目
                Do
                        iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3
                        tStream.Type = 1
                        tStream.Mode = 3
                        tStream.Open
                        oUpFileStream.Position = iFormStart
                        oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
                        tStream.Position = 0
                        tStream.Type = 2
                        tStream.CharSet = "gb2312"
                        sInfo = tStream.ReadText                        
                        '取得表单项目名称
                        iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1
                        iFindStart = InStr (22,sInfo,"name=""",1)+6
                        iFindEnd = InStr (iFindStart,sInfo,"""",1)
                        sFormName = Mid(sinfo,iFindStart,iFindEnd-iFindStart)
                        '如果是文件
                        If InStr (45,sInfo,"filename=""",1) > 0 Then
                                Set oFileInfo = new FileInfo_Class
                                '取得文件属性
                                iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10
                                iFindEnd = InStr (iFindStart,sInfo,""""&vbCrLf,1)
                                sFileName = Trim(Mid(sinfo,iFindStart,iFindEnd-iFindStart))
                                oFileInfo.FileName = GetFileName(sFileName)
                                oFileInfo.FilePath = GetFilePath(sFileName)
                                oFileInfo.FileExt = GetFileExt(sFileName)
                                iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
                                iFindEnd = InStr (iFindStart,sInfo,vbCr)
                                oFileInfo.FileMIME = Mid(sinfo,iFindStart,iFindEnd-
iFindStart)
                                oFileInfo.FileStart = iInfoEnd
                                oFileInfo.FileSize = iFormStart -iInfoEnd -2
                                oFileInfo.FormName = sFormName
                                file.add sFormName,oFileInfo
                        else
                        '如果是表单项目
                                tStream.Close
                                tStream.Type = 1
                                tStream.Mode = 3
                                tStream.Open
                                oUpFileStream.Position = iInfoEnd
                                oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
                                tStream.Position = 0
                                tStream.Type = 2
                                tStream.CharSet = "gb2312"
                                sFormValue = tStream.ReadText
                                If Form.Exists (sFormName) Then
                                        Form (sFormName) = Form (sFormName) & ", " &  
sFormValue
                                        else
                                        Form.Add sFormName,sFormValue
                                End If
                        End If
                        tStream.Close
                        iFormStart = iFormStart+iStart+2
                        '如果到文件尾了就退出
                Loop Until (iFormStart+2) >= iFormEnd
                if Err.number<>0 then OutErr("分解上传数据时发生错误,可能客户端的上传数据不
正确或不符合上传数据规则")
                RequestBinDate = ""
                Set tStream = Nothing
                isGetData_=true
        end if
End Sub

'保存到文件,自动覆盖已存在的同名文件
Public Function SaveToFile(Item,Path)
        SaveToFile=SaveToFileEx(Item,Path,True)
End Function

'保存到文件,自动设置文件名
Public Function AutoSave(Item,Path)
        AutoSave=SaveToFileEx(Item,Path,false)
End Function

'保存到文件,OVER为真时,自动覆盖已存在的同名文件,否则自动把文件改名保存
Private Function SaveToFileEx(Item,Path,Over)
        On Error Resume Next
        Dim FileExt
        if file.Exists(Item) then
                Dim oFileStream
                Dim tmpPath
                isErr_=0
                Set oFileStream = CreateObject ("ADODB.Stream")
                oFileStream.Type = 1
                oFileStream.Mode = 3
                oFileStream.Open
                oUpFileStream.Position = File(Item).FileStart
                oUpFileStream.CopyTo oFileStream,File(Item).FileSize
                tmpPath=Split(Path,".")(0)
                FileExt=GetFileExt(Path)
                if Over then
                        if isAllowExt(FileExt) then
                                oFileStream.SaveToFile tmpPath & "." & FileExt,2
                                if Err.number<>0 then OutErr("保存文件时出错,请检查路径,是否
存在该上传目录!该文件保存路径为" & tmpPath & "." & FileExt)
                                Else
                                isErr_=3
                                ErrMessage_="该后缀名的文件不允许上传!"
                                OutErr("该后缀名的文件不允许上传")
                        End if
                        Else
                        Path=GetFilePath(Path)
                        dim fori
                        fori=1
                        if isAllowExt(File(Item).FileExt) then
                                do
                                        fori=fori+1
                                        Err.Clear()
                                        tmpPath=Path&GetNewFileName()&"."&File(Item).FileExt
                                        oFileStream.SaveToFile tmpPath
                                loop Until ((Err.number=0) or (fori>50))
                                if Err.number<>0 then OutErr("自动保存文件出错,已经测试50次
不同的文件名来保存,请检查目录是否存在!该文件最后一次保存时全路径为"&Path&GetNewFileName()
&"."&File(Item).FileExt)
                                Else
                                isErr_=3
                                ErrMessage_="该后缀名的文件不允许上传!"
                                OutErr("该后缀名的文件不允许上传")
                        End if
                End if
                oFileStream.Close
                Set oFileStream = Nothing
        else
                ErrMessage_="不存在该对象(如该文件没有上传,文件为空)!"
                OutErr("不存在该对象(如该文件没有上传,文件为空)")
        end if
        if isErr_=3 then SaveToFileEx="" else SaveToFileEx=GetFileName(tmpPath)
End Function

'取得文件数据
Public Function FileData(Item)
        isErr_=0
        if file.Exists(Item) then
                if isAllowExt(File(Item).FileExt) then
                        oUpFileStream.Position = File(Item).FileStart
                        FileData = oUpFileStream.Read (File(Item).FileSize)
                        Else
                        isErr_=3
                        ErrMessage_="该后缀名的文件不允许上传"
                        OutErr("该后缀名的文件不允许上传")
                        FileData=""
                End if
        else
                ErrMessage_="不存在该对象(如该文件没有上传,文件为空)!"
                OutErr("不存在该对象(如该文件没有上传,文件为空)")
        end if
End Function


'取得文件路径
Public function GetFilePath(FullPath)
  If FullPath <> "" Then
    GetFilePath = Left(FullPath,InStrRev(FullPath, "\"))
    Else
    GetFilePath = ""
  End If
End function

'取得文件名
Public Function GetFileName(FullPath)
  If FullPath <> "" Then
    GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
    Else
    GetFileName = ""
  End If
End function

'取得文件的后缀名
Public Function GetFileExt(FullPath)
  If FullPath <> "" Then
    GetFileExt = LCase(Mid(FullPath,InStrRev(FullPath, ".")+1))
    Else
    GetFileExt = ""
  End If
End function

'取得一个不重复的序号
Public Function GetNewFileName()
        dim ranNum
        dim dtNow
        dtNow=Now()
        randomize
        ranNum=int(90000*rnd)+10000
        '以下这段由webboy提供
        GetNewFileName=year(dtNow) & right("0" & month(dtNow),2) & right("0" & day(dtNow),2)  
& right("0" & hour(dtNow),2) & right("0" & minute(dtNow),2) & right("0" & second(dtNow),2) &  
ranNum
End Function

Public Function isAllowExt(Ext)
        if NoAllowExt="" then
                isAllowExt=cbool(InStr(1,";"&AllowExt&";",LCase(";"&Ext&";")))
                else
                isAllowExt=not CBool(InStr(1,";"&NoAllowExt&";",LCase(";"&Ext&";")))
        end if
End Function
End Class

Public Sub OutErr(ErrMsg)
if IsDebug_=true then
        Response.Write ErrMsg
        Response.End
        End if
End Sub

'------------------------------------------------------------------------------------------
----------
'文件属性类
Class FileInfo_Class
Dim FormName,FileName,FilePath,FileSize,FileMIME,FileStart,FileExt
End Class
%>
搜索更多相关主题的帖子: excel 表格 Microsoft include admin 
2012-02-01 22:17
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:4 
session.CodePage=936  
session本身就没有这个属性,LZ要做什么?Excel乱码转换?
2012-02-02 15:05
快速回复:求助,Microsoft VBScript 运行时错误 '800a01b6'
数据加载中...
 
   



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

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