+ -
当前位置:首页 → 问答吧 → mdb数据库如何转换编码???

mdb数据库如何转换编码???

时间:2008-03-08

来源:互联网

我的asp网页原本是gb编码的,但由于某原因,都把他转为utf-8编码了,结果导致数据库的数据显示全乱码了,只是数据库的数据乱码,网页本身输出的文字没有.请问如何转换mdb数据库的编码为utf-8啊???

作者: jjtthl   发布时间: 2008-03-08

改codepage了吗?

作者: 萧萧小雨   发布时间: 2008-03-08

改了啊,把所有要加的header都加了

作者: jjtthl   发布时间: 2008-03-08

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.CodePage="65001"%>
<% Response.charset="UTF-8" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

都加了吗

作者: roomspirit   发布时间: 2008-03-08

都加了啊,但还是不行.而且文件也用记事本另存为了格式utf-8了.

作者: jjtthl   发布时间: 2008-03-09

那你因为你的以前的数据本身不是UFT-8编码,所以就成这样了
必须进行转换
复制内容到剪贴板
代码:
<%
response.codepage=936
response.charset="gb2312"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("news.mdb")
conn.open connstr
set rs=server.CreateObject("ADODB.RecordSet")
sql="select title,author,keyword from PE_Article"
rs.open sql,conn,1,3
do while not rs.eof
rs("title")=xx(rs("title"))
rs("author")=xx(rs("author"))
rs("keyword")=xx(rs("keyword"))
rs.movenext
loop
rs.updateBatch
rs.close
set rs=nothing
conn.close
set conn=nothing
function xx(fileContent)
dim stm
set stm=Server.CreateObject("adodb.stream")
stm.Type=2
stm.Mode=3
stm.Charset="UTF-8"
stm.Open
stm.WriteText fileContent
stm.Position=0
stm.Charset="GB2312"
xx = stm.ReadText
stm.Close
set stm=nothing
End function
%>
[ 本帖最后由 sparrow1981 于 2010-7-31 10:24 编辑 ]

作者: sparrow1981   发布时间: 2010-07-31

相关阅读 更多