日期:2014-05-17  浏览次数:20746 次

无法连接数据库
<%  
dim   rs,conn,sql,connstr
dim   strSQLServer,strSQLUser,strSQLPassword,strSQLDatabase
strSQLServer= "(local) "
strSQLUser= "sa "
strSQLPassword= " "
strSQLDatabase= "abs_data "
connstr   =   "driver={SQL   Server};server= "   &   strSQLServer   &   ";UID= "   &   strSQLUser   &   ";PWD= "   &   strSQLPassword   &   ";database= "   &   strSQLDataBase   &   " "
set   conn   =   server.createobject( "ADODB.CONNECTION ")
   
        if   err.number <> 0   then
err.clear
set   conn=nothing
response.write   " <script> window.status= " "创建   ADO   对象失败 " "; </script> "
response.end
else
conn.open   connstr

if   err.number <> 0   then
err.clear
set   conn=nothing
response.write   " <script> window.status= " "SQL   Server   数据库连接失败 " "; </script> "
' ' '请检查数据库是否存在,以及   ODBC   是否存在
response.end
end   if
end   if

set   rs   =   Server.CreateObject( "ADODB.Recordset ")           '主程序用
          sql= "select   *   from   member "
            rs.open   sql,conn,1,1
%>
<table   border= "3 "   bordercolor= "#000033 "   cellpadding= "0 "   cellspacing= "0 "   width= "770 "   heigth= "550 ">
<tr   bgcoler= "#445566 ">
<%
      for   i=0   to   rs.fields.count-1
response.write " <td> "&rs.fields(i).name& " </td> "
next
response.write " <td> number </td> "
response.write " <td> check </td> "
%>
<%
do   while   not   rs.eof
data= " <tr   bgcolor= "#aabbcc "> "
for   i=0   to   rs.fields.count-1
  data=data& " <td   colspan= "3 "> "&rs.fields(i).value
next
response.write   data& " </td> </tr>
rs.movenext
loop
rs.close
set   rs=nothing
conn.close
set   conn=nothing
%> </table>
以上的代码在IE中显示时什么都没有,连接的数据库中有东西.

------解决方案--------------------
你自己看看这个tr还有结束标记
......
%>
<table border= "3 " bordercolor= "#000033 " cellpadding= "0 " cellspacing= "0 " width= "770 " heigth= "550 ">
<tr bgcoler= "#445566 ">
<%
......