当前位置:编程学习 > VB >>

asp+mysql数据库连接问题

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body style=" margin:0; padding:0; text-align:center;">


<%


dim myHost,myDB,myUID,myPWD
myHost = "127.0.0.1"
myDB = "zzmx"
myUID = "root2"
myPWD = "root2"
myChareSet = "gb2312"
strconnection="driver={mysql odbc 5.1 driver};server=" & myHost & ";database=" & myDB & ";user=" & myUID & ";password=" & myPWD
set conn = server.createobject("adodb.connection") 
'连接数据库
conn.open strconnection
'设置客户端字符编码
conn.execute("set names '" & myChareSet & "'")



set rsnewa=server.createobject("adodb.recordset")
sql="select top 1 * from com_link where article_isdel=0"
rsnewa.open sql,conn,1,3 
count=0
if rsnewa.Bof then
response.write "<FONT COLOR='#FF0000'><div align='center'>还没有发布!</div></FONT>" 
else
do while not rsnewa.eof
%>
     <img src="uploadfile/<%=rsnewa("article_upload")%>" width="133" height="90" />
     <%
rsnewa.movenext
loop
end if
rsnewa.close
set rsnewa=nothing

%>
</body>
</html>




页面报错内容:
Microsoft OLE DB Provider for ODBC Drivers '80040e14' 

[MySQL][ODBC 5.1 Driver][mysqld-5.5.8]SET NAMES not allowed by driver 

\index3.asp, line 26


所说的26行就是      conn.execute("set names '" & myChareSet & "'")   这行代码...
尝试过把这行代码去掉,但去掉了就出现乱码...

--------------------编程问答-------------------- 我也遇到了,帮顶\\\\
补充:VB ,  COM/DCOM/COM+
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,