死亡有感觉吗:SQL语句问题

来源:百度文库 编辑:高校问答 时间:2024/04/30 13:11:21
有这样的一条语句:
sql="select top 10 from cbc where type='"&程序&"' order by id desc"

运行时出错。
如果这里写中文,怎样写
type='"&程序&"'

把两边的"&去掉,&&之间,会认为"程序"二字为一变量。

sql="select top 10 from cbc where type='程序' order by id desc"

或者
typeName = "程序"
sql="select top 10 from cbc where type='"&typeName&"' order by id desc"

同意楼上的
“程序”应该是一个值,你那样做就相当于把“程序”这个东东当成了一个变量。