如何将&formPath&File.FileName&这种字段读入数据库?

cwdn 2002-07-20 09:21:10
麻烦死了,谁能帮帮我?

<!--#include FILE="upload_5xsoft.inc"-->
<html>
<head>
<title>文件上传</title>
</head>
<body>
<br>文件上传!<hr size=1 noshadow width=300 align=left><br><br>

<%
dim upload,file,formName,formPath,iCount
set upload=new upload_5xSoft ''建立上传对象

response.write upload.Version&"<br><br>" ''显示上传类的版本

if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if
dim rs1
dim rs

Set rs1=Server.CreateObject("ADODB.command")
set rs=server.createobject("ADODB.Recordset")
rs1.CommandText = "SELECT * FROM sp where 日期=date() "
rs1.CommandType = 1
Set rs1.ActiveConnection = conn
rs.Open rs1, , 1, 3
rs.addnew


iCount=0
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
rs("dt")="&formPath&File.FileName&"
response.write file.FilePath&file.FileName&" ("&file.FileSize&") => "&formPath&File.FileName&" 成功!<br>"
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing ''删除此对象
Htmend iCount&" 个文件上传结束!"

sub HtmEnd(Msg)
set upload=nothing
response.write "<br>"&Msg&" [<a href=""javascript:history.back();"">返回</a>]</body></html>"
response.end
end sub
%>
...全文
93 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cwdn 2002-07-22
  • 打赏
  • 举报
回复
还是不行
cwdn 2002-07-20
  • 打赏
  • 举报
回复
sql="insert into sp(dt)values('"&formPath&File.FileName&"')"
conn.execute(sql)
出现报错
Microsoft JET Database Engine (0x80040E14)
cmsoft 2002-07-20
  • 打赏
  • 举报
回复
sql="insert into sp(dt)values('"&formPath&File.FileName&"')"
conn.execute(sql)
cwdn 2002-07-20
  • 打赏
  • 举报
回复

&formPath&File.FileName& 不能接受Recordset
skyarrow 2002-07-20
  • 打赏
  • 举报
回复
rs("dt")="&formPath&File.FileName&"
改为
rs("dt")="&formPath&File.FileName&"
rs.update
cmsoft 2002-07-20
  • 打赏
  • 举报
回复
rs("dt")="&formPath&File.FileName&"
这句什么意思?
写成这样吧:
sql="insert into tblname("……")values("……")"
conn.execute(sql)
yonghengdizhen 2002-07-20
  • 打赏
  • 举报
回复

sql也Response.Write出来。
检查你的最终执行的SQL文本,在数据环境中测试一下运行结果。
yonghengdizhen 2002-07-20
  • 打赏
  • 举报
回复
Response.Write formPath&File.FileName
Response.End
看看,估计可能在你的formPath&File.FileName中有SQL非法字符
cwdn 2002-07-20
  • 打赏
  • 举报
回复
怎么?!没人回答了,

又要浪费这一百分?

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧