06 Sep 2010 
Support Center » Knowledgebase » How to connect to MySQL database from ASP? 如何設定ASP連接MySQL數據庫?
 How to connect to MySQL database from ASP? 如何設定ASP連接MySQL數據庫?
Solution Below is the sample codes for ASP connecting MySQL database:
以下是程式碼範例關於ASP連接 MySQL數據庫:

<%@ CodePage=65001 %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<%
strConnection = "driver={MySQL ODBC 5.1 Driver};server=localhost;uid=mysqldbdemo;pwd=VmSPqRQh;database=mysqldbdemo;"
Set adoDataConn = Server.CreateObject("ADODB.Connection")
adoDataConn.Open strConnection

strQuery = "SELECT * FROM test;"
Set rs = adoDataConn.Execute(strQuery)

If Not rs.BOF Then
%>
<TABLE>
<%
Do While Not rs.EOF
%>
<TR><TD><%=rs("fielda")%></TD><TD><%=rs("fieldb")%></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
%>
</body>
</html>


Article Details
Article ID: 38
Created On: 08 Dec 2009 11:51 AM

 This answer was helpful  This answer was not helpful

 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
 
 Search
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads
Language:

Help Desk Software By Kayako eSupport v3.60.04