vb.net汉字乱码问题

linanir77 2015-08-30 10:50:40
tableinput.aspx文件,内容如下:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="tableinput.aspx.vb" Inherits="tableinput" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
</style>
</head>
<script type="text/javascript" src="jquery-2.1.3.js"></script>
<script type="text/javascript" src="JavaScript.js" ></script>
<body>
<form id="form1" runat="server">
<div style="width:auto;height:auto;display:table;clear:both;overflow:auto;background-color:firebrick">
<div id="d1" runat="server" style="max-width:100%;width:auto; height:100%;position:relative;display:block;float:right;clear:none;background-color:peachpuff">
</div>
</div>
<script type="text/javascript">
$.loadp = function () {
}
$(function () { $.loadp(); })
</script>
</form>
</body>
</html>

tableinput.aspx.vb文件,内容如下:
Imports System.Data
Imports System.Data.OleDb
Partial Class tableinput
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim cnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\testc\testvbandnet5\test.accdb;Persist Security Info=False"
Dim sql As String
sql = "select * from 表格汇总表 where 表名='" & Request.QueryString("page") & "'"
cn = New OleDbConnection(cnStr)
da = New OleDbDataAdapter(sql, cn)
ds = New DataSet
Response.Write(sql)
End Sub
End Class

在浏览器中输入地址:http://localhost/tableinput.aspx?page=%E7%9B%91%E6%8E%A7%E7%82%B9%E8%AE%BE%E8%AE%A1%E8%A1%A8_1

得到的页面如下:
select * from 琛ㄦ牸姹囨€昏〃 where 琛ㄥ悕='监控点设计表_1'

问题:通过request.querystring得到的内容“监控点设计表_1”没问题,但是我在tableinput.aspx.vb页面中的变量sql
(sql = "select * from 表格汇总表 where 表名='" & Request.QueryString("page") & "'"),汉字部分(表格汇总表、表名)是乱码。
但是其他的页面,比如我的asprespond.aspx和asprespond.aspx.vb文件中的汉字都是正常的,只有上面的页面里面汉字是乱码。不是变量传递的问题,因为通过get传递过来的变量都是正常的。
...全文
408 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
linanir77 2015-08-31
  • 打赏
  • 举报
回复
问题解决了,但是不知道怎么解决的,原来的tableinput.aspx和tableinput.aspx.vb文件是我在microsoft code(刚发布的轻量级代码编辑器)里面建立的,我原来的页面都是在visual studio里面建立的。我用visual studio重新建立了页面,把代码复制进去就ok了,只是改动了以下两处。 把下面的tableinput改成新文件名 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="tableinput.aspx.vb" Inherits="tableinput" %> 把下面的tableinput改成新文件名 Partial Class tableinput 其他地方没有改动,然后就正常了。跟我改动的内容没关系,所以我考虑是visual studio建立的文件里面有什么隐藏的内容。
Justin-Liu 2015-08-31
  • 打赏
  • 举报
回复
编码格式问题
threenewbee 2015-08-30
  • 打赏
  • 举报
回复
看看你的页面保存为utf-8了没有。

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧