ASP页面中SQL语句出错

xsxcjj 2004-04-12 05:07:21
SQL语句中大量关键字不能使用
select * from tablename
通过
但加入where或order by 子句就会出错
另外select 后面跟字段名也会出错!

出错信息如下:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

ODBC driver does not support the requested properties.

请大侠指教!
...全文
46 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xsxcjj 2004-04-13
  • 打赏
  • 举报
回复
Iamarmy(IT民工),你好,感谢你的发言。采用你的驱动方式后
在执行
select* from tablename where条件
语句打开表时
出现如下错误提示


Microsoft JET Database Engine error '80004005'

Selected collating sequence not supported by the operating system.

/01-Gallery/001-carpets/carpets-public.asp, line 325
Iamarmy 2004-04-12
  • 打赏
  • 举报
回复
StrCnn="Driver={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("../../db/")&"/dtt.mdb;"

Cnn.Open StrCnn

=〉

Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../db/dtt.mdb"),"Admin"
Iamarmy 2004-04-12
  • 打赏
  • 举报
回复
StrCnn="Driver={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("../../db/")&"/dtt.mdb;"

=〉

Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../db/dtt.mdb"),"Admin"



"select * from type where cstr(id)='"&tp&"'"

=〉
如果id是长整形的话改成
sqlstr = "select * from [type] where id=" & CLng(tp)
如果是字符串型改成
sqlstr = "select * from [type] where id=""" & tp & """"


xsxcjj 2004-04-12
  • 打赏
  • 举报
回复
谢谢各位大侠指教,但是还是没有解决问题!
望大侠们施以援手!小弟感激涕零!!!
sxsgssgs 2004-04-12
  • 打赏
  • 举报
回复
set xm1=server.CreateObject("adodb.recordset")
xm1.Open "select * from type where id="&Cint(tp) ,Cnn,1,1
xyqxj 2004-04-12
  • 打赏
  • 举报
回复
"select * from type where cstr(id)='"&tp&"'"
这条语句错了
正确的应该是 "select * from type where id="&tp
xsxcjj 2004-04-12
  • 打赏
  • 举报
回复
谢谢各位的关注,操作系统是windows 2003英文标准版,代码都是从以前windows2000as英文版拿过来的,以前都运行没问题!
现在出现了很多ODBC错,而且新添加的系统DSN也无法连接上!
61 2004-04-12
  • 打赏
  • 举报
回复
关键字用[]括起
set rs=server.CreateObject("adodb.recordset")
sqlstr = "select * from [type] where id='" & tp & "'"
rs.Open sqlstr,Cnn,1,1
如果字段ID为数值类型则
set rs=server.CreateObject("adodb.recordset")
sqlstr = "select * from [type] where id=" & tp
rs.Open sqlstr,Cnn,1,1
luluso 2004-04-12
  • 打赏
  • 举报
回复
xm1.Open "select * from type where cstr(id)='"&tp&"'" ,Cnn,1,1
不用cstr(id)吧?你数据库里都有约束了!
改成:
xm1.Open "select * from type where [id]='"&tp&"'" ,Cnn,1,1
luluso 2004-04-12
  • 打赏
  • 举报
回复
把你的sql语句贴出来!
pizixt 2004-04-12
  • 打赏
  • 举报
回复
这样不行吗?
xm1.Open "select * from type where id="&tp,Cnn,1,1
银狐被占用 2004-04-12
  • 打赏
  • 举报
回复
关键字用[]括起来就能用了。
xsxcjj 2004-04-12
  • 打赏
  • 举报
回复
Set Cnn= Server.CreateObject("ADODB.Connection")
StrCnn="Driver={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("../../db/")&"/dtt.mdb;"
Cnn.Open StrCnn

set xm1=server.CreateObject("adodb.recordset")
xm1.Open "select * from type where cstr(id)='"&tp&"'" ,Cnn,1,1

当把xm1.open语句中的where子句去掉后,就没有错误了
FlashK 2004-04-12
  • 打赏
  • 举报
回复
关键字你就加[]了。
select * from [tablename]
firstboy 2004-04-12
  • 打赏
  • 举报
回复
把代码贴出来看一下才知道呀

28,391

社区成员

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

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