上传xls文件到服务器,再导入数据库的ASP代码的问题

来源:百度知道 编辑:UC知道 时间:2024/06/15 17:58:55
下面的网址中已有一段相关的代码:
http://zhidao.baidu.com/question/72578514.html

但作者没把相关的代码完整发上来,其中function.asp中定义了代码中使用的 Message()函数,具体代码是什么?,还有是upfilego.asp和conn.asp的代码呢?还有在inAccess.asp中能否加一条,如果数据库中已存有
“ID”相同的记录将提示“有数据重复,不能导入,希望高手指点,能不能把代码发到的我QQ邮箱?(65128562@qq.com)能用的话,一定加分~!

示例(假设上传文件不成问题):
这里上传模块,并得到文件名
filename=文件路径+文件名
dim connexl
Set connexl = Server.CreateObject("ADODB.Connection")
connexl.Open "Driver={Microsoft Excel Driver (*.xls)};Dbq="&server.MapPath(filename)&""
dim rsexl,i,rs1,bz
set rsexl=server.CreateObject("adodb.recordset")
rsexl.open "select * from [mode$]",connexl,0,1
if rsexl.Fields(0).name<>"号码" then
response.Write "<script>alert('导入的Excel表格式不正确,请重新导入!');history.go(-1)</script>"
response.End()
end if
Do While Not (rsexl.eof or rsexl.bof)
Response.Flush()
数据插入语句

rsexl(0),rsexl(1),rsexl(2)表示XSL的字段
Response.Flush()

Rsexl.movenext
loop
Rsexl.close:set Rsexl=nothing
Next
Response.Write "全部修改成功!"
End If

网上可以下载