以下是我正在处理的 ASP 代码:
Dim sConnString, connection, sSQL, backgroundColor
sSQL = "SELECT firstName, lastName, email, zip, country, company, industry, revenue, timestamp FROM users"
sConnString=//a connection string
Set connection = Server.CreateObject("ADODB.Connection")
connection.Mode=adModeRead
connection.Open(sConnString)
connection.execute(sSQL)
Response.Write"<table>"
do while not connection.EOF
if(backgroundColor="#f1f1f1")then
backgroundColor="#ffffff"
else
backgroundColor="#f1f1f1"
end if
response.write"<tr backgroundColor="& backgroundColor & "></td>" & connection("firstName") & "</td><td>" & connection("lastName") & "</td><td>" & connection("email") & "</td><td>" & connection("zip") & "</td><td>" & connection("country") & "</td><td>" & connection("company") & "</td><td>" & connection("industry") & "</td><td>" & connection("revenue") & "</td><td>" & connection("timestamp") & "</td></tr>"
connection.MoveNext
Loop
Response.Write"</table>"
connection.Close
Set connection = Nothing
我收到以下错误:
ADODB.Connection 错误“800a0bb9”
参数类型错误、超出可接受范围或相互冲突。
/wsu.asp,第 13 行
第 13 行:
do while not connection.EOF
你能帮我解决这个问题吗?
更新代码:
<html>
<body>
<%
Dim sConnString, connection, sSQL, backgroundColor
sSQL = "SELECT firstName, lastName, email, zip, country, company, industry, revenue, timestamp FROM users"
sConnString="a connection string for MS SQL database;"
Set connection = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
connection.Mode=adModeRead
rs.open sSQL,connection
Response.Write"<table>"
do while not connection.EOF
if(backgroundColor="#f1f1f1")then
backgroundColor="#ffffff"
else
backgroundColor="#f1f1f1"
end if
response.write "<tr backgroundColor="& backgroundColor & "></td>" & connection("firstName") & "</td><td>" & connection("lastName") & "</td><td>" & connection("email") & "</td><td>" & connection("zip") & "</td><td>" & connection("country") & "</td><td>" & connection("company") & "</td><td>" & connection("industry") & "</td><td>" & connection("revenue") & "</td><td>" & connection("timestamp") & "</td></tr>"
connection.MoveNext
Loop
Response.Write"</table>"
connection.Close
Set connection = Nothing
%>
</body>
</html>