让ASP搭配MYSQL
所需要工具
mysql-4.1.11-win32
myodbc-3.51.11-1-dll
myodbc-3.51.11-1-win
mysqlcc-0.9.4-win32
-------------------------------------------------------------------
注册文件Mydbc.reg
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\myodbc driver]
"UsageCount"=dword:00000002
"Driver"="C:\\WINDOWS\\System\\myodbc.dll"
"Setup"="C:\\WINDOWS\\System\\myodbc.dll"
"SQLLevel"="1"
"FileUsage"="0"
"DriverODBCVer"="03.51"
"ConnectFunctions"="YYY"
"APILevel"="1"
"CpTimeout"="120"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"myodbc driver"="installed"
-------------------------------------------------------------------
建立ASP文件链接数据库
例子如下
Windows DSN name: 所要建立DSN的名称
Mysql Host (name or ip):Mysql服务器的名称或者是IP地址,通常填localhost
Mysql database name: admin
Database: admin
password: 000000
Port(if not 3306):
SQL command on connect:
下面两种链接数据库的ASP代码
1. 使用DSN
<%
strConnection = "dsn=admin;driver={myodbd driver};server=localhost;uid=root;pwd=000000;database=admin"
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.Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>
2. 不使用DSN
<%
strconnection="DefaultDir=;Driver={myodbc driver};database=admin"
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.Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>
所需要工具
mysql-4.1.11-win32
myodbc-3.51.11-1-dll
myodbc-3.51.11-1-win
mysqlcc-0.9.4-win32
-------------------------------------------------------------------
注册文件Mydbc.reg
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\myodbc driver]
"UsageCount"=dword:00000002
"Driver"="C:\\WINDOWS\\System\\myodbc.dll"
"Setup"="C:\\WINDOWS\\System\\myodbc.dll"
"SQLLevel"="1"
"FileUsage"="0"
"DriverODBCVer"="03.51"
"ConnectFunctions"="YYY"
"APILevel"="1"
"CpTimeout"="120"
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]
"myodbc driver"="installed"
-------------------------------------------------------------------
建立ASP文件链接数据库
例子如下
Windows DSN name: 所要建立DSN的名称
Mysql Host (name or ip):Mysql服务器的名称或者是IP地址,通常填localhost
Mysql database name: admin
Database: admin
password: 000000
Port(if not 3306):
SQL command on connect:
下面两种链接数据库的ASP代码
1. 使用DSN
<%
strConnection = "dsn=admin;driver={myodbd driver};server=localhost;uid=root;pwd=000000;database=admin"
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.Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>
2. 不使用DSN
<%
strconnection="DefaultDir=;Driver={myodbc driver};database=admin"
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.Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>
标签:
让ASP搭配MYSQL
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“让ASP搭配MYSQL”评论...