| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1032 人关注过本帖
标题:关于EXCEL导入ACESS数据的问题,红色显示错误
只看楼主 加入收藏
jyhwcec
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2021-3-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
关于EXCEL导入ACESS数据的问题,红色显示错误
<!--#include virtual="/include/dbconn.inc"-->
<%
if request.Cookies("shiwei_username")="" then
%>
<script language="javascript">
top.location.href="../index.asp"
</script>

<%  
  response.end
end if
%>
<!--#include file="uploadx.asp"-->
<%
'on error resume next
Dim filePath
Dim fileName
Dim fileExt
Dim file_subject
Dim Sql
Dim msg
Dim errflag
Dim errnumber
Dim SavePath
Dim maxfilesize

SavePath = "file"                                    '虚拟路径(后面不要加"/"符号)
maxfilesize = 50*1024                                    '大小为50M

Errflag=false
filePath = SavePath                                        '使用虚拟路径进行赋值,如"/www"或"www"等
filePath = Server.MapPath(filePath)                        '将虚拟路径转换为磁盘路径
file_subject = GetFormVal("tables1")                    '取得文件标题
fileext = GetFormVal("bank")                            '取得文件介绍
errnumber = GetFormVal("errnumber")                        '取得报错方式



filename = SaveFile("fruit",filePath,maxfilesize,2,1)    '保存并取得文件名
                                                                '    0,1            唯一文件名方式,如果有同名则自动改名;
                                                                '    1,1            报错方式,如果有同名则出错;
                                                                '    2,[0|1]        覆盖方式,如果有同名则覆盖原来的文件


sheet = file_subject
bank = fileext



dim filename_2
dim count_num

filename_2 = Split(filename,"|")
'On Error Resume Next
db="\produit\file\"&filename_2(0)
Server.ScriptTimeOut = 999999
'set conn=CreateObject("ADODB.Connection")
'conn.Open "driver={SQL Server};server=server2003;uid=sa;pwd=;database=exceltest;" '导入的数据库名称
set conn=Server.CreateObject("ADODB.Connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/data/!##jxc##!.mdb") '建立数据库连接


Set conne = Server.CreateObject("ADODB.Connection")
'Driver = "Driver={Microsoft Excel Driver (*.xls)};"
'DBPath = "DBQ=" &Server.MapPath(""&db&"")
' 调用Open 方法打开excel
'response.Write Driver & DBPath &"<br>"
'myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(""&db&"") &";Extended Properties=Excel 8.0;IMEX=2;"
 myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"") & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""

response.Write myConn_Xsl
'response.End()
conne.Open myConn_Xsl

Set rse = Server.CreateObject("ADODB.Recordset")
' 打开Sheet,参数二为Connection对象,因为Excel ODBC驱动程序无法直接用'sheet名来打开sheet,所以请注意以下的select语句

rse.Open "Select *  From ["&sheet&"$]", conne
'response.Write "Select *  From ["&sheet&"$]"&"<br>"

sql="select * from shoukuanjihua where zuxmbm='"& fixsql(rse(3)) &"' and  htbm='"& fixsql(rse(6)) &"'"
set rs=conn.execute(sql)
if rs.eof=false then
%>
<script language="javascript">
alert("您导入的项目已经存在,请重新导入!")
window.history.go(-1)
</script>
<%
response.end
end if

while not rse.eof
sql = "insert into shoukuanjihua(xuhao,zixmbm,zixmmc,zuxmbm,cbdq,leixing,htbm,htmc,htje,khbm,khmc,zixllzx,zixcbzx,zixmjl,khjl,cpsrx,ywlx,fpzl,shuilv,jhqrzjehs,jhqrzjebhs,yjqrrq,sjqrrq,lcbjd,srcfxt,jhzt,zhaiyao,sfgljy,spzt,SAPrq,xmywlx,xmgkbm,htqyrq)values("& fixsql(rse(0)) &",'"& fixsql(rse(1)) &"','"& fixsql(rse(2)) &"','"& fixsql(rse(3)) &"','"& fixsql(rse(4)) &"','"& fixsql(rse(5)) &"','"& fixsql(rse(6)) &"','"& fixsql(rse(7)) &"',"& fixsql(rse(8)) &",'"& fixsql(rse(9)) &"','"& fixsql(rse(10)) &"','"& fixsql(rse(11)) &"','"& fixsql(rse(12)) &"','"& fixsql(rse(13)) &"','"& fixsql(rse(14)) &"','"& fixsql(rse(15)) &"','"& fixsql(rse(16)) &"','"& fixsql(rse(17)) &"',"& fixsql(rse(18)) &","& fixsql(rse(19)) &","& fixsql(rse(20)) &",#"& fixsql(rse(21)) &"#,#"& fixsql(rse(22)) &"#,'"& fixsql(rse(23)) &"','"& fixsql(rse(24)) &"','"& fixsql(rse(25)) &"','"& fixsql(rse(26)) &"','"& fixsql(rse(27)) &"','"& fixsql(rse(28)) &"',#"& fixsql(rse(29)) &"#,'"& fixsql(rse(30)) &"','"& fixsql(rse(31)) &"',#"& fixsql(rse(32)) &"#)"
conn.execute(sql)
rse.movenext
Response.Write "正在插入 "&sql&"<Br>"
count_num=count_num+1
response.Write count_num&"<br>"
Response.Flush
wend

conne.close
set conne = Nothing

If Err = 0 Then
Response.Write "成功导入"&count_num&"条记录"

Else
Response.Write "导入失败!"
End If

function fixsql(str)
dim newstr
newstr = str
if isnull(newstr) then
newstr = ""
else
newstr = replace(newstr,"'","''")
end if
fixsql = newstr
end Function

Call update_insert(fileext,count_num)
%>

<html>
<head>
<title>收入收款计划导入成功</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="/css/sport_style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
    font-size: 12px;
}
a {
    font-size: 12px;
    color: #000000;
}
a:link {
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #000000;
}
a:hover {
    text-decoration: underline;
    color: #000000;
}
a:active {
    text-decoration: none;
    color: #000000;
}
.style1 {color: #FF0000}
-->
</style></head>

<body class="h1">
<table width="700" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"  >
        <tr>
          <td>&nbsp; </td>
        </tr>
        <tr>
          <td> <div align="center">
              <table width="600" border="0" cellpadding="0" cellspacing="0" bgcolor="#CBDFF3">
                <tr>
                  <td width="15" height="15"> </td>
                  <td    width="570"></td>
                  <td width="15" height="15"> </td>
                </tr>
                <tr>
                  <td colspan="3"> <div align="center">
                      <table width="599" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td class="P093"> <div align="center">
                              <center>
                              </center>
                            </div></td>
                        </tr>
                        <tr>
                          <td class="P093"> <div align="center">
                              <hr width=500>
                            </div></td>
                        </tr>
                        <tr>
                          <td class="P093"> <div align="center">
                              <p><font size="1"><%response.Write "数据导入完毕,共导入"&count_num&"条记录"%></font><br><br>
                              <span class="style1"><font size="1">切不可重复导入以免出现大量无用数据</font></span></p>
                              <script language="javascript">window.location.href="piliang.asp"</script>
                              <p> </p>
                            </div></td>
                        </tr>
                        <tr>
                        
                          <td class="P093"> <div align="center">
                              <hr width=500>
                            </div></td>
                        </tr>
                        <tr>
                          <td class="P093"> <div align="center"> <font color="#FFFFFF">&nbsp;&nbsp;
                              </font> </div></td>
                        </tr>
                      </table>
                    </div></td>
                </tr>
                <tr>
                  <td width="15" height="15"> </td>
                  <td    width="570"></td>
                  <td width="15" height="15"> </td>
                </tr>
              </table>
            </div></td>
        </tr>
        <tr>
          <td>&nbsp; </td>
        </tr>
      </table></td>
  </tr>
</table>

</body>
</html>
搜索更多相关主题的帖子: response div Server 导入 Dim 
2022-09-14 16:14
jyhwcec
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2021-3-8
收藏
得分:0 
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\服务器\produit\file\fileError;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"
ADODB.Recordset 错误 '800a0cc1'

在对应所需名称或序数的集合中,未找到项目。
我看了N多遍查不到问题,哪位老师帮我看看
2022-09-14 16:15
好学
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:622
专家分:318
注 册:2004-5-4
收藏
得分:20 
是不是因为数据库里面没有记录,查不到结果,导致结果为空?
2022-09-15 18:30
快速回复:关于EXCEL导入ACESS数据的问题,红色显示错误
数据加载中...
 
   



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

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