关于'"'"和&的问题

EvrlLa 2010-12-24 04:47:30
<%
if country<>"" then
sql="SELECT Companyname,Contactname,Country FROM Customers WHERE country='" & country & "'"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>

上个'" & country & "'"中的country是由request.form传的参数(country=request.form("country"))
...全文
59 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
EvrlLa 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 aspwebchh 的回复:]
country 是数字类型就不要加 '号了
[/Quote]
不是
EvrlLa 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xming4321 的回复:]
country='" & repalce(country,"'","''") & "'"
[/Quote]
没看懂括号里那几个单引号和双引号
EvrlLa 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sallyimportant 的回复:]
感觉你的单引号用的不对啊?应该是在半角状态下的单引号!你的country是什么类型的啊?字符型吗?
[/Quote]
我是抄的,还在自己机子上运行了,么的问题。country是字符串类型
叶子 2010-12-24
  • 打赏
  • 举报
回复

增加函数
function Do_add(table,direct)
set rs=server.createobject("adodb.recordset")
sql="select * from "&table&" where (id is null)"
rs.open sql,conn,1,3
rs.addnew
for i= 1 to rs.fields.count-1
rs(i)=request(rs(i).name)
next
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.Redirect direct
end function

给你个例子,你的sql字符串有问题。
挨踢直男 2010-12-24
  • 打赏
  • 举报
回复
country 是数字类型就不要加 '号了
十一文 2010-12-24
  • 打赏
  • 举报
回复
country='" & repalce(country,"'","''") & "'"
sallyimportant 2010-12-24
  • 打赏
  • 举报
回复
感觉你的单引号用的不对啊?应该是在半角状态下的单引号!你的country是什么类型的啊?字符型吗?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧