广东因建筑得名的地方:sql="select * from spzs where id="+cstr(id)+" order by id desc" 意思

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/08 06:31:05
sql="select * from spzs where id="+cstr(id)+" order by id desc"
在ASP中是查询意思,不过我对CSTR()函数不大明白,而且这里有“+”号,而有的查询又不需要“+”号,请帮忙详细解释一下,请不要复制其他网站上的东西给我看,我看的头疼。。。。谢谢。。。请指教。

cstr()函数:转换成字符串变量型态

"+"号等同于"&"

不过这句是有错误的

如果ID是数值型,那么就不应该用cstr,应该用cint

如果ID是字符型,那么就应该是sql="select * from spzs where id='"+cstr(id)+"' order by id desc"

要加上单引号

CSTR()强制将ID转化为string也就是字符串类型
关于这个函数你参考一下http://bbs.51soft.com/doc/vbscript/html/vsfctCStr.htm

+号是连接前后的字符串成为一体吧,cstr是把id转换为string类型吧