asp连接sqlserver 高手赐教

结果是什么也不显示

也不报错

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
   <%
   dim  strServer,strUid,strPwd,strDatabase
   strServer="(local)"
   strUid="sa"
   strPwd=""
   strDatabase="jiandan"
  
   Dim Conn '数据库连接
   Dim StrDSN '数据库连接字符串
   Dim Rs '命令字符串
  
   StrDSN="driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database="&strDatabase
  
   set Conn=server.CreateObject("ADODB.Connection")
   set rs=server.CreateObject("ADODB.RecordSet")
   Conn.open StrDSn
  
   dim strsql
  
   sub readdb()
   strsql="select * from student"
   rs.open strsql,Conn,1,1
   if rs.EOF then response.write "no record at all":exit sub
   response.write "<table border=1>"
   response.write "<tr>"
   for i=0 to rs.Fields.Count-1
   response.write "<td><font color=blue>"&rs.Fields(i).Name&"</font></td>"
   next
   response.write "</tr>"
   while not rs.EOF
   response.write "<tr>"
   for i=0 to rs.Fields.Count-1
   response.write "<td>"&rs.Fields(i).Value&"</td>"
   next
   response.write "</tr>"
   rs.MoveNext
   wend
   response.write "</table>"
   rs.Close
   set rs=nothing
   Conn.close
   set Conn=nothing
   end sub
  


%>

</head>

 


<body>
</body>
</html>

你可能感兴趣的:(sqlserver)