ASP获取SQL-SERVER信息
SQL-SERVER 2005下有数据库BDCOM,该数据库下有表made,现要将made表的partsName字段信息显示于页面。代码如下,请大虾看一下问题在哪里?万分感谢!
以下是odbc_connection2.asp:
<%
Dim strconn,conn
strconn = "Driver={SQL Server};SERVER=(local);UID=sa;PWD=; Database = BDCOM"
set conn = Server.createobject("adodb.connection")
conn.open strconn
%>
以下是test.asp:
<!--#Include file="odbc_connection2.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%Dim rs,strSql
strSql ="Select * From made"
Set rs=db.Execute(strSql)
<%do while not rs.eof%>
<p align="left">商品简介:<%=rs("partsName")%></p>
<% rs.movenext loop %>
<% rs.Closeset
rs=nothing
conn.Close
set conn=nothing%>
</body></html>------解决方案--------------------
<!--#Include file="odbc_connection2.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
Dim rs,strSql
strSql ="Select * From made"
Set rs = conn.Execute(strSql)
Do while not rs.eof
%>
<p align="left">商品简介:<%=rs("partsName")%></p>
<%
rs.movenext
loop
rs.Close
set rs = nothing
conn.Close
set conn = nothing
%>
</body></html>
------解决方案--------------------Set rs=db.Execute(strSql)
改成Set rs=conn.Execute(strSql)
另外,最后的
rs.Closeset
rs=nothing
也写乱了。应该是
rs.close
set rs=nothing