| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 725 人关注过本帖
标题:求助,为什么数据库没有记录呢
只看楼主 加入收藏
bichaoguo
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2008-5-11
收藏
 问题点数:0 回复次数:6 
求助,为什么数据库没有记录呢
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
    conn.execute strSQL
next
set upload=nothing  
response.write "<SCRIPT language=JavaScript>alert('文件上传成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"

图片上传的代码

图片都可以上传到服务器。

但是数据库里,没有这条记录

上传的时候,没有错误显示

可以出现 文件上传成功,返回。

请问高手,这是什么原因呢?
以下是 conn.asp 的连接代码
<%
   dim conn   
   dim connstr
   'on error resume next
   connstr="DBQ="+server.mappath("../paladin/data/impaladin.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
   set conn=server.createobject("ADODB.CONNECTION")
   conn.open connstr
   
   function CloseConn()
   conn.close
   set conn=nothing
   end function
%>

以下是写如数据库的代码
<%
dim upload,file,formName,formPath,iCount,filename,fileExt,i,ranNum
set upload=new upload_5xSoft '建立上传对象

name=upload.form("name")
zhuanti=upload.form("zhuanti")
formPath="paladin"
photointro=HTMLEncode2(upload.form("photointro"))
if right(formPath,1)<>"/" then formPath=formPath&"/"
for each formName in upload.file '列出所有上传了的文件
    set file=upload.file(formName)  '生成一个文件对象
   
    if file.filesize<0 then
        response.redirect "info.asp?info=请选择上传的文件"
        response.end
    end if   
    if file.filesize>2000000 then
        response.redirect "info.asp?info=文件不得超过2M"
        response.end
    end if

    fileExt=lcase(right(file.filename,4))
    if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" and fileEXT<>".bmp" then
    response.redirect "info.asp?info=只允许上传gif,jPG,png,bmp文件!"
    response.end
    end if
    Dim Jpeg
   FilePath=Server.MapPath("../")'设置上传目录位置
   FilePath=Req(FilePath &"/"&formPath)
    Set Jpeg = Server.CreateObject("Persits.Jpeg")
If -2147221005=Err then
Response.write "没有ASPJPEG组件,或组件授权已到期,请安装!"
Response.End()
End If
ranNum=int(900*rnd)+112
    filenamett=file.FileName
    filenamet=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&fileExt
    filename=req(filepath&filenamet)
    ranNum=int(312*rnd)+109
    filesize=file.filesize
    if file.FileSize>0 then         '如果 FileSize > 0 说明有文件数据
        file.SaveAs filename   '保存文件
        else
    response.redirect "info.asp?info=文件错误!"
    response.end
    end if
   
     '变更扩展名
    Jpeg.Open (filename)
    '开始变更所有文件扩展名为jpg
    filenamelen=len(filenamet)
    filenamelen=filenamelen-4
    filenamet1=filenamet
    filenamet=left(filenamet,filenamelen)
    filenamet=filenamet&".jpg"
    '结束文件名变更
   
    '添加水印
Jpeg.Open filename
Jpeg.Canvas.Font.Color = &HA83C3C
Jpeg.Canvas.Font.Family = "宋体" 'family设置字体
Jpeg.Canvas.Font.Bold = false  '是否设置成粗体
Jpeg.Canvas.Font.Size = 12 '字体大小
Jpeg.Canvas.Font.Quality = 5'输出质量
Jpeg.Canvas.Print Jpeg.width-104, Jpeg.height-13, "www.2st.name"
Jpeg.Save filename
    set file=nothing
'结束水印

'开始缩图
    '判断哪边为长边,以长边进行缩放
    imgWidth=Jpeg.OriginalWidth
    imgHeight=Jpeg.OriginalHeight
    if imgWidth>=imgHeight and imgWidth>120 then
    Jpeg.Width=150
    Jpeg.Height=Jpeg.OriginalHeight/(Jpeg.OriginalWidth/150)
    end if
    if imgHeight>imgWidth and imgHeight>113 then
    Jpeg.Height=113
    Jpeg.Width=Jpeg.OriginalWidth/(Jpeg.OriginalHeight/113)
    end if
    '结束判断

    'ImgObj.SaveFile(FilePath & "small_" & filenamet)
    'end if
    'ImgObj.Free
    'Set ImgObj = nothing
    Jpeg.Sharpen 1, 130
    Jpeg.Save (FilePath & "small_" & filenamet)
   
    '缩图保存完毕
    '写入数据库
    yy=year(date)
    mm=right("00"&month(date),2)
    dd=right("00"&day(date),2)
    idate=yy & "-" & mm & "-" & dd & " "
    xx=right("00"&hour(time),2)
    ff=right("00"&minute(time),2)
    mm=right("00"&second(time),2)
    itime=xx & ":" & ff & ":" & mm
    itime=idate&itime
    photourlb=formPath & filenamet1
    'if imgwidth<320 and imgheight<240 then
    photourls=formPath & "small_" & filenamet
    'else
    'photourls=photourlb
    'end if
    strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
    conn.execute strSQL
next
set upload=nothing  
response.write "<SCRIPT language=JavaScript>alert('文件上传成功,返回!');"
response.write "this.location.href='addfile.asp?typeid="&zhuanti&"';</SCRIPT>"
function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function
Function Req(Str)
If IsEmpty(Str) Then Exit Function
Str = Lcase(Str)
do
A_len=len(Str)
Str = Replace(Str,Chr(0),"")
Str = Replace(Str,"asp","")
Str = Replace(Str,"asa","")
Str = Replace(Str,"aspx","")
Str = Replace(Str,"cer","")
Str = Replace(Str,"cdx","")
Str = Replace(Str,"htr","")
Str = Replace(Str,"asax","")
Str = Replace(Str,"ascx","")
Str = Replace(Str,"ashx","")
Str = Replace(Str,"asmx","")
Str = Replace(Str,"axd","")
Str = Replace(Str,"vsdiso","")
Str = Replace(Str,"rem","")
Str = Replace(Str,"soap","")
Str = Replace(Str,"config","")
Str = Replace(Str,"cs","")
Str = Replace(Str,"csproj","")
Str = Replace(Str,"vb","")
Str = Replace(Str,"vbproj","")
Str = Replace(Str,"webinfo","")
Str = Replace(Str,"licx","")
Str = Replace(Str,"resx","")
Str = Replace(Str,"resou","")
Str = Replace(Str,"jsp","")
Str = Replace(Str,"php","")
Str = Replace(Str,"cgi","")
str = Replace(str,"&nbsp;","")
str = Replace(str,"%5C","")
str = Replace(str,"%2F","")
str = Replace(str,"asp","")
str = Replace(str,"asa","")
str = Replace(str,"cer","")
str = Replace(str,"cdx","")
str = Replace(str,"mdb","")
str = Replace(str,"hrt","")
str = Replace(str,"aspx","")
str = Replace(str,"php","")
str = Replace(str,"jsp","")
str = Replace(str,"'","")
loop until A_len=len(Str)
Req=Str
End Function
%>

请高手帮忙解决一下。非常感谢!@
搜索更多相关主题的帖子: 数据库 记录 
2009-10-29 08:38
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
首先精简sql语句 看能否插入数据 如不能则可能是无权限 但是一般的服务器都有这个权限的吧
反正这些问题应该是化繁为简查找问题根源
2009-10-29 09:38
chenbofeng20
Rank: 4
来 自:陕西 宝鸡
等 级:业余侠客
威 望:3
帖 子:113
专家分:274
注 册:2009-9-18
收藏
得分:0 
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"
  response.write  strSQL  输出strSQL看看每个值是否取到了 一般是值没取到或者是上一页没有传到
  response.end()
conn.execute strSQL

2009-10-29 10:25
chenguoxing517
Rank: 7Rank: 7Rank: 7
来 自:广东广州
等 级:黑侠
威 望:1
帖 子:154
专家分:619
注 册:2009-9-28
收藏
得分:0 
看下你要插入到表的字段值是否取到了,当你要插入的字段值中某个没取到,而你的数据库表中该字段又不允许为空的时候,此记录就插入不成功!
2009-10-29 12:57
bichaoguo
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2008-5-11
收藏
得分:0 
谢谢楼上的各位,
aspic  你好,数据库的权限肯定是有的,因为我在加分类的时候,是正常的(一开始我也认为是权限的问题,)

chenbofeng20  chenguoxing517  我今天晚上来测试,有什么最新情况,我会如实反映,谢谢

如果我把数据库的这个字段改为允许为空,是否可以写入呢
2009-10-30 08:38
bichaoguo
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2008-5-11
收藏
得分:0 
按chenbofeng20 给的写法,
strSQL= "insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('"&name&"','"&zhuanti&"','"&photointro&"','"&itime&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&photourlb&"','"&photourls&"')"  
response.write  strSQL  输出strSQL看看每个值是否取到了 一般是值没取到或者是上一页没有传到
  response.end()  
conn.execute strSQL

页面出现 如下显示
insert into desktop ([name],zhuanti,jj,[time],imgh,imgw,filesize,url,surl) values ('DDDDDDDDD','13','DDDDDDDD','2009-10-30 13:33:32','','','9269','paladin/20091030133332746.jpg','paladin/small_20091030133332746.jpg')
好像图片大小,数据没有输入。图片大小数据库里 不是必写字段

为什么数据库里,还是显示不了呢?

2009-10-30 13:37
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
简化 排除
2009-10-30 14:37
快速回复:求助,为什么数据库没有记录呢
数据加载中...
 
   



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

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