asp的类型问题?

来源:百度知道 编辑:UC知道 时间:2024/06/07 00:08:16
这类型的引号用法真的是苦煞我们菜鸟.有没有高手来整结一下:
二楼的说明与三楼的说法相反.一个讲字符变量用双引号.别一个讲字符变量用单引号

首先,sql="select * from news where labey="&id&""一般不常用,基本上后面那个&和""没什么意义。除非你在这里面还加其他条件,比如像这样:sql="select * from news where labey="&id&" and 列名=XXXX"

sql="select * from news where id="&id 在这里和第一条没什么区别

sql="select * from labey where labey='" & labey & "'"这一句,后面…… labey='" & labey & "'"表示这个labey是个字符型的。所以在查询的时候要用引号将这个字段引号引起来

再简单的说下要点:
如果id是自动编号,那么查询就像这样写:
dim id
id=request("id")
sql="select * from news where id="&id
像这样写就错了:sql="select * from news where id='"&id&"'"

如果age是数字,那么查询就像这样写:
dim num
num=request("age")
sql="select * from student where age>"&num

像字符型的,查询的时候相关的参数就要加引号了,如:
dim newstitle定义一个参数
newstitle=request("title")接受传过来的名字输入框中的值
sql="select * from news where title='"&n