⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getauthors.asp

📁 Microsoft?ASP.NET Programming with Microsoft Visual C#?.NET Version 2003 Step By Step
💻 ASP
字号:
<%@ Language=VBScript %>
<html>
<head>
<%
Dim objConn
Dim objCmd
Dim objRS
Dim strConn

' Do NOT use the sa account in data access code! 
' Doing so is a MAJOR security risk!
' Either use a trusted connection, or use a 
' less-privileged account to access the database.
strConn = "PROVIDER=SQLOLEDB;INITIAL CATALOG=PUBS;" _
   & "SERVER=(local)\VSdotNET;uid=sa;pwd=;"
Set objConn = Server.CreateObject("ADODB.Connection")
Set objCmd = Server.CreateObject("ADODB.Command")
Set objRS = Server.CreateObject("ADODB.Recordset")

objCmd.CommandText = "SELECT * FROM Authors"
objConn.Open strConn
Set objCmd.ActiveConnection = objConn
Set objRS = objCmd.Execute

Sub FormatTable

   Dim objField

   If Not objRS.EOF Then
      Response.Write "<table border=2 cellspacing=0>"
      Do While Not objRS.EOF
         Response.Write "<tr>"
         For Each objField In objRS.Fields
            Response.Write "<td>" & objField & "</td>"
         Next
         Response.Write "</tr>"
         objRS.MoveNext
      Loop
      Response.Write "</table>"
   Else
      Response.Write "No Records!"
   End If

End Sub
Sub CleanUp()
   objConn.Close
   Set objConn = Nothing
   Set objCmd = Nothing
   Set objRS = Nothing
End Sub
%>
</head>
<body>

<%
FormatTable()
CleanUp()
%>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -