Connection.asp
<%
Response.Buffer=true
Dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOleDb.1;Data Source=(local);User ID=sa;Password=;Initial Catalog=Pubs"
'-----Connection 对象的属性-----
Response.Write(CStr(conn.ConnectionString) & "<p>")
Response.Write(CStr(conn.ConnectionTimeout) & "<p>")
Response.Write(CStr(conn.Attributes) & "<p>")
Response.Write(CStr(conn.DefaultDataBase) & "<p>")
Response.Write(CStr(conn.Mode) & "<p>")
Response.Write(CStr(conn.State) & "<p>")
Response.Write(CStr(conn.Version) & "<p>")
'-----Connection 对象的方法-----
Dim rs
Set rs=Conn.Execute("SELECT * FROM authors",,1) 'adCmdText
Set rs=Conn.Execute("authors",,2) 'adCmdTable
Set rs=Conn.Execute("authors",,512) 'adCmdTableDirect
Set rs=Conn.Execute("reptq1",,4) 'adCmdStoredProc
Set rs=Conn.OpenSchema(20) 'adSchemaTables
'-----测试语句-----
Dim i
Response.Write("<table><tr>")
For i=0 To rs.Fields.Count-1
Response.Write("<td>" & rs(i).Name & "</td>")
Next
Response.Write("</tr>")
Do While NOT rs.EOF
Response.Write("<tr>")
For i=0 To rs.Fields.Count-1
Response.Write("<td>" & rs(i) & "</td>")
Next
Response.Write("</tr>")
rs.MoveNext
Loop
rs.Close
Set rs=Nothing
conn.Close
Set conn=Nothing
%>
Response.Buffer=true
Dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOleDb.1;Data Source=(local);User ID=sa;Password=;Initial Catalog=Pubs"
'-----Connection 对象的属性-----
Response.Write(CStr(conn.ConnectionString) & "<p>")
Response.Write(CStr(conn.ConnectionTimeout) & "<p>")
Response.Write(CStr(conn.Attributes) & "<p>")
Response.Write(CStr(conn.DefaultDataBase) & "<p>")
Response.Write(CStr(conn.Mode) & "<p>")
Response.Write(CStr(conn.State) & "<p>")
Response.Write(CStr(conn.Version) & "<p>")
'-----Connection 对象的方法-----
Dim rs
Set rs=Conn.Execute("SELECT * FROM authors",,1) 'adCmdText
Set rs=Conn.Execute("authors",,2) 'adCmdTable
Set rs=Conn.Execute("authors",,512) 'adCmdTableDirect
Set rs=Conn.Execute("reptq1",,4) 'adCmdStoredProc
Set rs=Conn.OpenSchema(20) 'adSchemaTables
'-----测试语句-----
Dim i
Response.Write("<table><tr>")
For i=0 To rs.Fields.Count-1
Response.Write("<td>" & rs(i).Name & "</td>")
Next
Response.Write("</tr>")
Do While NOT rs.EOF
Response.Write("<tr>")
For i=0 To rs.Fields.Count-1
Response.Write("<td>" & rs(i) & "</td>")
Next
Response.Write("</tr>")
rs.MoveNext
Loop
rs.Close
Set rs=Nothing
conn.Close
Set conn=Nothing
%>