使用ADO连接SQL Server数据库的两种方式
1).
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Driver={SQL Server};Server=(local);Database=pubs;UID=sa;PWD=123"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open "select top 10 * from authors",conn
%>
2).
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;User ID=sa;Password=123;Initial Catalog=pubs;Data Source=(local)"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open "select top 10 * from authors",conn
%>
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Driver={SQL Server};Server=(local);Database=pubs;UID=sa;PWD=123"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open "select top 10 * from authors",conn
%>
2).
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Provider=sqloledb;User ID=sa;Password=123;Initial Catalog=pubs;Data Source=(local)"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open "select top 10 * from authors",conn
%>