一/网上找的教程ASP连接MYSQL的东东
<%
strconnection = "dsn=mysqldsn;"
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
strquery = "select * from b__wz_article"
set rs = adodataconn.execute(strquery)
if not rs.bof then
do while not rs.eof response.write rs("title") & "<br>"
rs.movenext
loop else
response.write("sorry, no data found.")
end if
rs.close
adodataconn.close
set rs = nothing
set adodataconn = nothing
%> 已经成功了,可以输出,但是输出的为乱码!
二/以下为编码设置
mysql> show variables like '%char%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:\Program Files\MySQL\share\charsets\ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)三/MYSQL数据库字段编码为GBK问题:怎样解决输出时的编码问题!
<%
strconnection = "dsn=mysqldsn;"
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
strquery = "select * from b__wz_article"
set rs = adodataconn.execute(strquery)
if not rs.bof then
do while not rs.eof response.write rs("title") & "<br>"
rs.movenext
loop else
response.write("sorry, no data found.")
end if
rs.close
adodataconn.close
set rs = nothing
set adodataconn = nothing
%> 已经成功了,可以输出,但是输出的为乱码!
二/以下为编码设置
mysql> show variables like '%char%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | D:\Program Files\MySQL\share\charsets\ |
+--------------------------+----------------------------------------+
8 rows in set (0.00 sec)三/MYSQL数据库字段编码为GBK问题:怎样解决输出时的编码问题!
修改安装目录下的 初始化配置文件 my.ini# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="E:/MySQL5/"
#Path to the database root
datadir="E:/MySQL5/Data/"# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=latin1 换成 gbk 或者 gb2312# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB客户端建立Connection后立即执行sql:SET NAMES gb2312
然后在该Connection下执行其他操作 比如插入数据 就没有乱码问题了Connect;
ExecuteSql("SET NAMES gb2312");
insert("...");
update..
select ..
..Close;