asp连接mysql的数据库语句

来源:百度知道 编辑:UC知道 时间:2024/06/17 10:56:29
1、set cn=server.createobject("ADODB.CONNECTION")
2、cn.open connstr "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("test.mdb")

以上是ASP连接ACCESS数据库的代码,不需要在机器端进行任何设置就可直接使用。

如果改为连接到MYSQL型的数据库(MDF),请问代码该怎么改?

"Driver={mysql};database=data;uid=userid;pwd=password;option=apc6;"
链接数据库的asp代码!
<%
strconnection = "dsn=hc188;driver={myodbd driver};server=localhost;uid=root;pwd=;database=hc188"
set adodataconn = server.createobject("adodb.connection")
adodataconn.open strconnection
strquery = "select * from user"
set rs = adodataconn.execute(strquery)
if not rs.bof then
%>
<table>
<tr>
<td<b>username</b></td>
<td><b>password</b></td>
</tr>
<%
do while not rs.eof
%>
<tr>
<td><%=rs("username")%></td>
<td><%=rs("password")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%
else
response.write("sorry, no data found.")
end if
rs.close
adodataconn.