连接代码1直接输入
<%
Dim my_conn, sql,rs
Set my_conn = createobject("ADODB.Connection")
my_conn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_ '服务器名
& "DATABASE=mybase;"_ '数据库名
& "UID=root;PWD=111; OPTION=35;" '用户名和密码
Set rs = Server.CreateObject("ADODB.Recordset")
%>
连接代码2用到了数据源
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.Open "DSN=mybase" ' 数据源名
下面是关闭和数据库的连接
my_conn.close ' Close database connection
Set my_conn = nothing 'obj variable released