×

Loading...
Ad by
  • 技多不压身,工到自然成:安省技工证书特训班,点击咨询报名!
Ad by
  • 技多不压身,工到自然成:安省技工证书特训班,点击咨询报名!

PLS COPY/PASTE INSIDE

<%@CodePage=65001 Language=VBScript %>
<%response.Charset = "utf-8"%>

<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr = "Provider=SQLOLEDB.1;...."
conn.Open connstr
Set rsprod=conn.execute ("select * from table1 where id=290 ")
date=rsprod("date")
spec=rsprod("spec")
name=rsprod("name") [it's defined as nvarchar]

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html" />
<link href="css/csss.css" rel="stylesheet" type="text/css">
<title> TestChinese 测试中文</title>
</head>
<table> <%=name%> - <%=spec%> - <%=date%> TestChinese 测试中文</table>

</html>
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / SQL Server 2005 里的中文数据到了ASP页面怎么就成一串串问号了?有行家知道吗?十万火急哦...谢谢!
    • You need nvarchar, nchar, or ntext in SQL server
      • 我在一个Table里试了几个Columns,没用。
        • Then you need to adjust your stored proc parameters with nvarchar(100) for the particular col
          ALTER PROCEDURE [dbo].[up_TEST_InsertROLIA]
          @FirstName nvarchar(50), --中文COL
          @LastName nvarchar(50),--中文COL
          @Company nvarchar(100)--中文COL
          As

          SET NOCOUNT ON
          ....

          Return 0
    • 是创建数据库时字符集用错了吧, 改成支持中文的collation.
      • collation 是中文
    • Can you read the Chinese directly on SQL server?
      • if you did, the check the setting of "charset" in your ASP.
        • details pls....or simple samples.
    • 再说详细点:中文数据在Management Studio, Open Table, query 都没问题,ASP里hard code的汉字也能显示,就是数据库里的中文数据到了页面就变了...
      • Have you checked the setting of charset?
      • Now I realize you are using classic ASP. So, check the following:
        Response.Codepage = 65001
        Response.CharSet = "UTF-8"
        • 我已成功显示中文在CLASSIC ASP "SELECT..."
          <%@CodePage=65001 Language=VBScript %>
          <%response.Charset = "utf-8"%>
          ....

          <%
          Set RS = server.CreateObject ("ADODB.Recordset")
          set dbConnection = server.CreateObject ("ADODB.Connection")
          dbConnection.Open Application("DB_ConnectionString")

          strSQL = "SELECT * FROM .....
          ....
          RS("Description") 是中文

          %>
          • 显示为???????100????? - 17CM?23.5CM - 2009-08 TestChinese 测试中文 Code 见内...
            <%
            Set conn = Server.CreateObject("ADODB.Connection")
            connstr = "Provider=SQLOLEDB.1;...."
            conn.Open connstr
            Set rsprod=conn.execute ("select * from table1 where id=290 ")
            date=rsprod("date")
            spec=rsprod("spec")
            name=rsprod("name") [it's defined as nvarchar]

            %>

            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
            <link href="css/csss.css" rel="stylesheet" type="text/css">
            <title> TestChinese 测试中文</title>
            </head>
            <table> <%=name%> - <%=spec%> - <%=date%> TestChinese 测试中文</table>

            </html>
            • 朋友, PLS CHANGE YOUR SETTING TO <%@CodePage=65001 Language=VBScript %> <%response.Charset = "utf-8"%>
              • 我的code 的最前两行就是<%@CodePage=65001 Language=VBScript %> <%response.Charset = "UTF-8"%>,只不过没有放到前一个帖子里。。。就是不工作哦...
                • PLS COPY/PASTE INSIDE
                  <%@CodePage=65001 Language=VBScript %>
                  <%response.Charset = "utf-8"%>

                  <%
                  Set conn = Server.CreateObject("ADODB.Connection")
                  connstr = "Provider=SQLOLEDB.1;...."
                  conn.Open connstr
                  Set rsprod=conn.execute ("select * from table1 where id=290 ")
                  date=rsprod("date")
                  spec=rsprod("spec")
                  name=rsprod("name") [it's defined as nvarchar]

                  %>

                  <html>
                  <head>
                  <meta http-equiv="Content-Type" content="text/html" />
                  <link href="css/csss.css" rel="stylesheet" type="text/css">
                  <title> TestChinese 测试中文</title>
                  </head>
                  <table> <%=name%> - <%=spec%> - <%=date%> TestChinese 测试中文</table>

                  </html>
                • 我的CODE能显DATABASE的中文. 但是如果你又HARDCODE中文在ASP中, 这过就有点麻烦. 你的CODE咋过这么花骚呐?
                • 进展:数据库里取出的中文显示了,刚才没看见是因为IE的Encoding设为简体中文,若改成UTF-8就看到了。BUT:ASP里hard coding的中文就看不到了,比如“测试中文”几个字都变&#65533;&#65533;。请问如何二者兼得?谢谢!
                  • 咋过这么花骚呐?
                    • :) 有解吗?
                    • 我也不想啊...拿来的现成code而已。。。没辙了?
                      • 用XML 或DATABASE 来对应了. 不过要麻烦一点. 好多这种PAGES?
                        • XML是个好主意。
                        • 非常感谢!
    • 先看看具体存在数据库里的数据是不是正常的中文。如果在数据库里就不对,那就是那就是这个数据库,或者这张表,或者这个字段的字符集不对。如果数据库里的内容是正常的,那就是网页的字符集不对。
      • 请问怎么查数据库里的数据是不是正常的中文?“正常”是怎么定义的?
        • 写个sql一句话看看直接从数据库里拿出来的东西是不是正常的中文。select 字段名from 表名 where id = xxx
          • 从Mgmt Studio's New Query run SQL select 都没问题,可在ASP里Set ArtRs = Conn.Execute("Select field1...") 然后用<%=Artrs("field1")%>显示数据就成?了。这算“正常”吗?
            • Can you please post your asp here? or search the whole asp and look for "charset" and tell me what its setting is.
    • 你需要做一次字符集转换。
      在Java中是这么用的。

      try {
      content = new String(content.getBytes("GB2312"), "utf8");
      } catch (UnsupportedEncodingException e) {
      try {
      content = new String(content.getBytes("GB2312"), "utf-8");
      } catch (UnsupportedEncodingException e1) {
      }
      }