说我列名无效 到底为什么?

来源:百度知道 编辑:UC知道 时间:2024/05/28 19:30:50
是这样的,Candidate表中有人的Id和部门(CanId ,Appdepart),比如我传递参数cid为市场调查 ,要在Departments表内找对应的DepId 但是运行时就有错误

错误类型:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
列名 '市场调查' 无效。
/Mis/hr/admin/Canremove.asp, 第 30 行

还有我明明列名DepName 有的 表名也没错啊 这是什么情况?

cid = Request.QueryString("cid")
sql="select * from Candidate Where CanId=" & cid
set rs1 = Conn.Execute(sql)
Appdepart=rs1("Appdepart")
sql="select * from Departments where DepName = " & Appdepart
set rs3 = Conn.Execute(sql)
DepId= rs3("DepId")
是asp的页面问题

很明显,你sql语句有问题。sql="select * from Departments where DepName = " & Appdepart 。这里,你Appdepart接收到的是中文吧?需要用单引号括起来。

你在程序里传过去的参数是中文?

加单引号

无论是否是中文,只要属性列是字符型的就要加单引号