vb.net汉字乱码问题
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传递过来的变量都是正常的。