ASP操作Mysql,asp读取mysql数据,asp操作mysql表,asp修改mysql表,asp删除mysql表
在此只是读取了mysql表,其他跟asp操作access,sql一样
'定义mysql的地址,用户名,密码,以及库名
dim mysql_address,mysql_username,mysql_password,mysql_DBName
mysql_address="localhost"
mysql_username="root"
mysql_password="root"
mysql_tableName="fisker_table"
'连接数据库
dim conn
dim connstr
connstr = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER="&mysql_address&"; DATABASE="&mysql_DBName&"; UID="&mysql_username&";PASSWORD="&mysql_password&"; OPTION=3"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
'查询记录
dim sql
sql="select * FROM TABLE_NAME"
dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
If rs.eof Then
Response.Write("No records returned.")
Else
Do While not rs.eof
Response.write rs("FIRST_FIELD_NAME")
Response.write rs("SECOND_FIELD_NAME")
Response.write rs("THIRD_FIELD_NAME")
rs.MoveNext
Loop
End If
rs.Close
Set rs=nothing
conn.Close
Set conn=nothing
%>