ASP当中的嵌套语句怎么会出错呢?错哪里了啊?
<%@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>
</head>
<body>
<%//该文档是添加新书的成功文档。但是用本地连接。我将改成ODBC连接。
dim sql
dim bbID,bbName,bbPub,bbDate,bbAuthor,bbMem,bbCnt
bbID=Request.Form("bID")
bbName=Request.Form("bName")
bbPub=Request.Form("bPub")
bbDate=Request.Form("bDate")
bbAuthor=Request.Form("bAuthor")
bbMem=Request.Form("bMem")
bbCnt=Request.Form("bCnt")
dim rs
set rs=Session("s_DBConn").Execute("SELECT * FROM Book WHERE bID='"&bbID&"'")
if bbID="" then Response.Write"<div id='result' style='display:none'>2</div>"
Else
if NOT rs.EOF then
//该书已经存在
Response.Write"<div id='result' style='display:none'>1</div>"
else //如果该书没有添加
set sql=Session("s_DBConn").Execute("INSERT INTO Book(bID,bName,rPub,bDate,bAuthor,bMem,bCnt) VALUES('"&bbID&"','"&bbName&"','"&bbPub&"','"&bbDate&"','"&bbAuthor&"','"&bbMem&"','"&bbCnt&"')")
response.Write"<div id='result' style='display:none'>0</div>"
end if
end if
%>
</body>
</html>
程序运行之后,浏览器报出我的嵌套出现语法错误。这是错在哪里呢?报的是第一个ELSE出错。
------解决方案--------------------
把这段SQL写出来
VBScript code
"INSERT INTO Book(bID,bName,rPub,bDate,bAuthor,bMem,bCnt) VALUES ('"&bbID&"','"&bbName&"','"&bbPub&"','"&bbDate&"','"&bbAuthor&"','"&bbMem&"','"&bbCnt&"')"