注册 登录
编程论坛 ASP技术论坛

SQL-asp问题。,进来看,报的这个错误?怎么解决哦!

lzh0908 发布于 2011-12-12 20:14, 556 次点击
以下是代码:
  set rs_buy =server.createobject("ADODB.RecordSet")
  sql="select * from odplan where isnew=1"
  if nowstartdate<>"" and nowenddate<>"" then
  sql=sql&" and plandate between '"&startenddate&"' and '"&nowenddate&"' "
  end if
  if nowkeyword<>"" then
    sql=sql&" and (orderno like '%"&nowkeyword&"%' or orderno in (select id from odplan where daogoutxt like '%"&nowkeyword&"%') or shejishi in (select id from odplan where fcqk like '%"&nowkeyword&"%'))"
  end if
以下是报错:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]在将 varchar 值 'PA00001' 转换成数据类型 int 时失败。

单独运行
sql=sql&" and (orderno like '%"&nowkeyword&"%' )"
  这样不报错。子查询就报上面的错误!数据库是SQL2008 脚本类型是ASP
2 回复
#2
lzh09082011-12-13 09:09
自己顶
#3
xmlz2011-12-13 14:25
不能将varchar数据类型值'PA00001'转换到int,这个结合表就好排查了
1