asp读sql数据时出现乱码问题的解决方法

来源:互联网 发布:java windows界面开发 编辑:程序博客网 时间:2024/06/05 09:30
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
 

如果你在做网站的时候,无法正确执行sql语句,response后,发现sql语句里面的中文字段都成了乱码,可以用下面的方法解决:

 

<%@ codepage=936%>简体中文 <%@ codepage=950%>繁体中文 <%@ codepage=65001%>UTF-8

 

 

codepage指定了IIS按什么编码读取传递过来的串串(表单提交,地址栏传递等)。

 

出乱码的原因也就是网站要整合的时候模块编码不一样引起的。

 

最方便的方法如下:

 

不要转换任何模块网页的编码该utf-8的还是utf-8,该Gb22312的还是Gb2312。

在Utf-8模块的包文件(如conn.asp,但是要注意conn.asp必须是在第一行调用)最前面加上:

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <%Session.CodePage=65001%>

 

 

在GB2312模块的包文件最前面加上:

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <%Session.CodePage=936%>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击