上传的时候报如下错误:我在数据库中看到的是乱码,不能显示中文,只能显示数字或是字母。为什么??
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。
/insertlaigao.asp, 第 115 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)
代码如下
<%
Response.Expires=0
Function bin2str(binstr)
Dim varlen,clow,ccc,skipflag
skipflag=0
ccc = ""
If Not IsNull(binstr) Then
varlen=LenB(binstr)
For i=1 To varlen
If skipflag=0 Then
clow = MidB(binstr,i,1)
If AscB(clow) > 127 Then
ccc =ccc & Chr(AscW(MidB(binstr,i+1,1) & clow))
skipflag=1
Else
ccc = ccc & Chr(AscB(clow))
End If
Else
skipflag=0
End If
Next
End If
bin2str = ccc
End Function
varByteCount = Request.TotalBytes
bnCRLF = chrB( 13 ) & chrB( 10 )
binHTTPHeader=Request.BinaryRead(varByteCount)
Divider = LEFTB( binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF ) - 1 )
'开始读非文件域的数据
Do while lenB(binHTTPHeader)>46
binHeaderData = LeftB(binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF & bnCRLF )-1)
strHeaderData=bin2str(binHeaderData)
lngFieldNameStart=Instr(strHeaderData,"name="&chr(34))+Len("name="&chr(34))
lngFieldNameEnd=Instr(lngFieldNameStart,strHeaderData,chr(34))
strFieldName=Mid(strHeaderData,lngFieldNameStart,lngFieldNameEnd-lngFieldNameStart)
strFieldName=Trim(strFieldName)
strFieldName=Replace(strFieldName,vbcrlf,vbnullstring)
'判断文件数据时候开始
If strComp(strFieldName,"FileUploadStart",1)=0 Then
binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))
exit do
End if
DataStart = INSTRB( binHTTPHeader, bnCRLF & bnCRLF ) + 4
DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart
binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )
strFieldValue=bin2str(binFieldValue)
strFieldValue=Trim(strFieldValue)
strFieldValue=Replace(strFieldValue,vbcrlf,vbnullstring)
'非文件上传域变量赋值
execute strFieldName&"="""&strFieldValue&""""
binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))
loop
'开始处理文件数据
Do while lenB(binHTTPHeader)>46
binHeaderData = LeftB(binHTTPHeader, INSTRB( binHTTPHeader, bnCRLF & bnCRLF )-1)
strHeaderData=bin2str(binHeaderData)
'读取上传文件的Content-Type
lngFileContentTypeStart=Instr(strHeaderData,"Content-Type:")+Len("Content-Type:")
strFileContentType=Trim(Mid(strHeaderData,lngFileContentTypeStart))
strFileContentType=Replace(strFileContentType,vbCRLF,vbNullString)
'读取上传的文件名
lngFileNameStart=Instr(strHeaderData,"filename="&chr(34))+Len("filename="&chr(34))
lngFileNameEnd=Instr(lngFileNameStart,strHeaderData,chr(34))
strFileName=Mid(strHeaderData,lngFileNameStart,lngFileNameEnd-lngFileNameStart)
strFileName=Trim(strFileName)
strFileName=Replace(strFileName,vbCRLF,vbNullString)
'读取上传文件数据
DataStart = INSTRB( binHTTPHeader, bnCRLF & bnCRLF ) + 4
DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart
If strFileName<>"" Then
binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )
'将上传的文件写入数据库
set conn=server.createobject("adodb.connection")
conn.open"dsn=qikan"
SQL="select * from laigaodengji"
set rs=server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,3
rs.addnew
rs("zhongwentimu")=zhongwentimu
rs("laigaoriqi")=laigaoriqi
rs("yingwentimu")=yingwentimu
rs("lanmu")=lanmu
rs("keyword")=keyword
rs("zuozhe")=zuozhe
rs("jijinxiangmu")=jijinxiangmu
rs("laigaodanwei")=laigaodanwei
rs("lianxiren")=lianxiren
rs("zhaiyao")=zhaiyao
rs("FileContentType")=strFileContentType //此行出错,
rs("FileContent").AppendChunk binFieldValue
rs.update
rs.close
set rs=Nothing
conn.Close
set conn=Nothing
End if
binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))
loop
%>
<a href="index1.asp">返回</a>