关于在select * from .....中只用变量的问题

immc1979 2004-04-12 11:09:50
这样写有什么错误

dim keyword
dim aaa
dim size

keyword="aa.txt"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT * FROM file where filename like '%"&keyword&"%' ORDER BY filesize DESC"
rs.open strSQL,Conn,3,3
aaa=rs("filename")

Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "SELECT * FROM CACHINFO where FILENAME ="&aaa,conn,3,3 <-问题出在这里吧,应该怎么写?
size=rs1("filesize")
...全文
9 点赞 收藏 17
写回复
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
immc1979 2004-04-12
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=192.168.0.1;UID=mydat;PWD=123456;DATABASE=db3000"
这里select到的记录不是唯一的,有问题么?

总是提示“类型不匹配”
回复
qihboy 2004-04-12
不应该把''去掉.去掉就错了.
回复
diveas 2004-04-12
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"&aaa&"'",conn,3,3
应该把''去掉吧。
rs1.open "SELECT * FROM CACHINFO where FILENAME ="&aaa&"",conn,3,3
回复
diveas 2004-04-12
rs1.open "SELECT * FROM CACHINFO where FILENAME ="&aaa&"",conn,3,3
回复
immc1979 2004-04-12
还是返回“类型不匹配”:(
回复
try52000 2004-04-12
对不起,有错了
dim keyword
dim aaa
dim size

keyword="aa.txt"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT * FROM file where filename like '%"&keyword&"%' ORDER BY filesize DESC"
rs.open strSQL,Conn,3,2


Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"& rs("filename") &"'",3,2 size=rs1("filesize")
回复
try52000 2004-04-12
对不起,错了
dim keyword
dim aaa
dim size

keyword="aa.txt"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT * FROM file where filename like '%"&keyword&"%' ORDER BY filesize DESC"
rs.open strSQL,Conn,3,2


Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"& rs("filename") &"',3,2 size=rs1("filesize")
回复
try52000 2004-04-12
dim keyword
dim aaa
dim size

keyword="aa.txt"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT * FROM file where filename like '%"&keyword&"%' ORDER BY filesize DESC"
rs.open strSQL,Conn,3,2


Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"& rs("filename") &"'3,2 size=rs1("filesize")
回复
immc1979 2004-04-12
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=192.168.0.1;UID=mydat;PWD=123456;DATABASE=db3000"

dim keyword
dim aaa
dim size

keyword="aa.txt"

Set rs = Server.CreateObject("ADODB.Recordset")
strSQL ="SELECT * FROM file where filename like '%"&keyword&"%' ORDER BY filesize DESC"
rs.open strSQL,Conn,3,3
aaa=rs("filename")

Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "SELECT * FROM CACHINFO where FILENAME ="&aaa,conn,3,3 <-问题出在这里吧,应该怎么写?
size=rs1("filesize")
回复
driftarter 2004-04-12
数据库连接方式有问题,你贴出来分析
回复
immc1979 2004-04-12
各位前辈,显示Provider 错误 '80020005' 类型不匹配。

回复
skyboy0720 2004-04-12
同意!
回复
qzriso 2004-04-12
FILENAME 是不是字符型的,如果是:
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"&aaa&"'",conn,3,3
回复
QCB181 2004-04-12
同意楼上的
回复
whghwujx 2004-04-12
sqlstr="SELECT * FROM CACHINFO where FILENAME ="&aaa
rs1.open sqlstr,conn,3,3
或者
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"&aaa&"'",conn,3,3
回复
jiffer 2004-04-12
rs1.open "SELECT * FROM CACHINFO where FILENAME ='"&aaa&"'",conn,3,3 <-问题出在这里
回复
immc1979 2004-04-12
各位高手关注一下呀!!!
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告