知识库

ASP程序直接连接MYSQL数据库

来源: 本站    类别: 知识库    日期: 2012/1/7

 

在网上查找大量资料,经过自己的不懈努力,终于测试成功了。原来要在服务器上安装mysql odbc 3.51 ,还有数据库用户名及密码,用下面的密码就可以了。

以下为引用的内容:

<%
strconnection="driver={mysql odbc 3.51 driver};database=weste_net;server=localhost;uid=root;password="
set conn = server.createobject("adodb.connection")
conn.open strconnection

strquery = "select * from News"
set rs = conn.execute(strquery)
if not rs.bof then
%>

<table>
<tr>
<td<b>序列号</b></td>
<td><b>标题</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("NTitle")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("无暂时没有.")
end if
rs.close
conn.close
set conn = nothing
set rsdata = nothing
%>


相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com