在sql中我们经常使用语句
selet * from table1 where name = '王明'
可是这句要是放到网页制作中,'王明'换成一个变量UserName,就变成了
strSQL = "selet * from table1 where name = ' " &UserName& " '"
我不明白" &UserName& " 为什么要这么写,这一对双引号是做什么的,两个&符号是连接字符串的操作符吗,还是表示引用,请问这种引用方式是属于什么的语法asp,vbs还是sql?
strSQL = "selet * from table1 where name = ' " &UserName& " '" 上面这个语句肯定是在你的asp文件中的了。asp字符串连接符是&,这个你知道的,所以,不难看出,strSQL是由三部分组成的:1. "selet * from table1 where name = ' "2. UserName3. " '"如果你把语句显示到页面上,你就可以看到,真正的语句如下(假设UserName变量的值是‘王明’):selet * from table1 where name = '王明'这也是最终你的数据库要执行的语句。这就很容易解释了,双引号在AS...
1.双引号里面的表示是字符,如:strsql= "select * from table1"2.& 是连接字符串,前后都必须空格,"selet * from table1 where name =" & UserName表示是字符串加变量 Username3."selet * from table1 where name = ' " & Us...
你要整句来分析,那句话是这样的:"selet * from table1 where name = ' " &UserName& " '" 即:"selet * from table1 where name = ' " //字符串& //字符串连接符UserName //字符串& //字符串连接符" '"//字符串...