我正在尝试使用变量作为 SQL 中的列字段。但是,当我运行代码时,出现以下错误:
Microsoft VBScript compilation error '800a0408'
Invalid character
/junk/dbresults.htm, line 25
DECLARE @cat char(20)
--------^
代码如下:
<%
Dim connectString, connect, conDB, con
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_abn = Request.QueryString("abn")
src_cat = Request.QueryString("cat")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
DECLARE @cat char(20)
DECLARE @dynamicsql char(1000)
SET @cat = src_cat;
SET @dynamicsql = "SELECT * FROM cont.csv WHERE @cat='Yes'"
if src_abn = "all" then
conDB = EXEC (@DynamicSQL)
else
conDB = "SELECT * FROM cont.csv WHERE ucase(abn) LIKE ucase('%"+src_abn+"%')"
end if
set con = connect.execute(conDB)
%>