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

[求助]不知道是那裡錯了,看了半天還是沒有明白過來

xunmi_love 发布于 2007-11-06 14:54, 1294 次点击
<%
dim oskey,nian,yue,nam,hehe
oskey=request.form("odkey")
nian=request.form("nian")
yue=request.form("yue")
nam=request.form("renyuan")

hehe=nian&yue
set cn1=server.createobject("adodb.connection")
cn1.open"driver={microsoft access driver (*.mdb)};dbq="&server.mappath("dbsx\data\dbsx.mdb")
set rss=cn1.execute("select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'")

if rss.eof then
response.write"<tr><td>對不起。沒有你要找的內容,請重新搜索</td></tr>"
end if
response.write"<tr><td>代辦事項標題</td><td>完成時間</td><td>完成情況</td><td>代辦人員</td></tr>"
do while (not rss.eof)
response.write"<tr><td>"&rs("thingtitle")&"</td><td>"&rs("overtime")&"</td><td>"&rs("beizhu")&"</td><td>"&rs("renyuan")&"</td></tr>"
rss.movenext
loop
rss.close
set rss=nothing
cn1.close set cn1=nothing
%>

提示無說:第10行處少 ')'  ,我看了,有後半邊括號啊。這到底是怎麼回來,請高手幫忙!!!
20 回复
#2
xunmi_love2007-11-06 15:04

錯誤類型:
Microsoft VBScript 編譯階段錯誤 (0x800A03EE)
必須要有 ')'
/xitong/dbsx.asp, line 133, column 36


#3
永夜的极光2007-11-06 15:11
表名不需要用单引号,你去掉试试看

还有renyuan这个字段如果是文本型的,就要单引号

[此贴子已经被作者于2007-11-6 15:12:18编辑过]

#4
xunmi_love2007-11-06 15:14
我去掉了也試過,我的那個表名是數字的。數字是不是不可以做表名。但是他提示的是說少了半邊的括號。這是怎麼回事啊。
#5
永夜的极光2007-11-06 15:22
我刚试了一下,数字做表名没问题的,你要么改成这样

hehe=nian&yue
set cn1=server.createobject("adodb.connection")
cn1.open"driver={microsoft access driver (*.mdb)};dbq="&server.mappath("dbsx\data\dbsx.mdb")
set rss=cn1.execute("select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'")

改成

hehe=nian&yue
set cn1=server.createobject("adodb.connection")
cn1.open"driver={microsoft access driver (*.mdb)};dbq="&server.mappath("dbsx\data\dbsx.mdb")
dim sql
sql="select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'"
response.write(sql)
response.end

运行一下,把显示出来的sql语句,放到access里面运行一下看看行不行

[此贴子已经被作者于2007-11-6 15:23:29编辑过]

#6
xunmi_love2007-11-06 15:32

版主,你說的運行一下,是指在IE裡運行嗎?
可是IE裡面不行啊,頁面打不開呢!!!!

#7
永夜的极光2007-11-06 15:37
啊?提示什么错误?
#8
xunmi_love2007-11-06 15:38

錯誤類型:
Microsoft VBScript 編譯階段錯誤 (0x800A03EE)
必須要有 ')'
/xitong/dbsx.asp, line 259, column 37


瀏覽器類型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 2.0.50727)

頁數:
GET /xitong/dbsx.asp

時間:
2007年11月6日, 下午 03:36:42


其他資訊:
Microsoft Support

#9
cainiao1582007-11-06 22:13

你是香港那边的,还是台湾那边的?怎么用繁体!!!!

#10
zacom2007-11-06 22:45
set rss=cn1.execute("select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'")
改为
set rss=col.execute "select *from" &hehe&"where renyuan="&nam&"andthingtitle like '%"&oskey
看看
#11
madpbpl2007-11-07 01:35
以下是引用zacom在2007-11-6 22:45:14的发言:
set rss=cn1.execute("select * from '"&hehe&"' where
renyuan="&nam&" and thingtitle like '%"&oskey&"%'")
改为
set rss=col.execute "select *from" &hehe&"where renyuan="&nam&"andthingtitle like '%"&oskey
看看

注意一下sql语句的缩进

可能是&h的问题

set rss=cn1.execute("select * from '" & hehe & "' where renyuan="& nam &" and thingtitle like '%"& oskey &"%'")
问题应该出在红色部分,改成以上试试,或者把hehe改问试试,这里不方便调试,没有测试。

#12
hmhz2007-11-07 08:17
很明显,他的表是调用变量的,也就是不固定的,所以楼上的红色部分前后不能加单引号
set rss=cn1.execute("select * from "&hehe&" where renyuan="&nam&" and thingtitle like '%"&oskey&"%'")
#13
xunmi_love2007-11-08 14:51

????????????????还是没有解决

#14
hmhz2007-11-08 14:58

可能你的 renyuan 字段是文本类型的,所以 renyuan="&nam&" 要改成 renyuan='"&nam&"'

#15
xunmi_love2007-11-08 15:50

是不是FROM提交不可以在同一頁面啊?

我試了一下。把那些代碼放到別的頁面當中就可以,

但是入到FROM 所在的頁面裡就不行>不知道 是不是這個原因!!!!

#16
cainiao1582007-11-08 19:53
我估计没有收取到变量
#17
yms1232007-11-09 08:18
set rss=cn1.execute("select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'")
这句话改成下面的两句
set rss=server.createobject("adodb.recordset")
rss.open "select * from '"&hehe&"' where renyuan="&nam&" and thingtitle like '%"&oskey&"%'",cn1,1,1
#18
xunmi_love2007-11-09 09:57

還是不行。。。。。。

出現的問題還是以前那樣。我本想用IFRAME會好一點的,但是問題依就存在

#19
eakcon2007-11-09 16:48
全對啊
#20
hmhz2007-11-09 17:57
我怀疑,他传递过来的内容里有一个“(”这样的英文括号在里面
#21
xunmi_love2007-11-10 19:35

呵呵,沒有接,我試了好多次。只是傳到另外一個頁面上的時候就OK。但是要是傳到FROM自身的頁面的時候就會出現這樣的問題。。。不知道為什麼?????

1