数据库写入问题?
For n=LBound(MyArray) To UBound(MyArray)-1
temptid=""
temptid=temptid&myarray(n)&"|"
Conn.execute"update temp set temptid='"&temptid&"' where id="&i
response.write ""&temptid&""
Next
这样做,可以正确的显示出:
單詞記憶及辭典類|单词记忆|北京版小学英语单词表2002年版|
但却无法将其写入数据库,只能写入:北京版小学英语单词表2002年版|
这是怎么回事啊,望高手指教
问题点数:20、回复次数:14Top
1 楼batistuta97()回复于 2006-03-13 15:11:47 得分 0
For n=LBound(MyArray) To UBound(MyArray)-1
temptid=""
temptid=temptid&myarray(n)&"|"
Next
Conn.execute"update temp set temptid='"&temptid&"' where id="&i
response.write ""&temptid&""
执行放到外面啊Top
2 楼starchange(星变_浙江教育学院)回复于 2006-03-13 15:14:16 得分 0
呵呵。是啊……Top
3 楼yutian130(骑着布什好歹的萨达姆猪,漫步在小巷的尽头)回复于 2006-03-13 15:17:30 得分 0
就是就是。。。。。。。。Top
4 楼xscan(惊艳)回复于 2006-03-13 15:33:59 得分 0
这是错误的,按你说的这样,只能写入:北京版小学英语单词表2002年版|
完整的应该是:單詞記憶及辭典類|单词记忆|北京版小学英语单词表2002年版|
这个似乎是temptid的数据类型有关吧,不要想的太简单啊,有人知道吗Top
5 楼dadaoxiaoriben1(5333334444)回复于 2006-03-13 15:36:22 得分 0
学习Top
6 楼cyyno1(GunRose)回复于 2006-03-13 15:46:15 得分 10
For内第一行(temptid="")每次对temptid初始化,temptid只能取MyArray数组中最后一个的值,update一共执行了n次,写入数据库的是最后取得的MyArray(n)。
同样,response.write ""&temptid&""也执行了n次,在你的程序中分别输出了
單詞記憶及辭典類|、
单词记忆|、
北京版小学英语单词表2002年版|
,response.write对输出的内容连续显示以至欺骗了你!
Top
7 楼rainningsky()回复于 2006-03-13 15:46:31 得分 10
temptid=""
For n=LBound(MyArray) To UBound(MyArray)-1
temptid=temptid&myarray(n)&"|"
Conn.execute"update temp set temptid='"&temptid&"' where id="&i
response.write ""&temptid&""
Next
Top
8 楼batistuta97()回复于 2006-03-13 15:49:26 得分 0
同意rainningsky() ,没注意temptid=""。。。Top
9 楼batistuta97()回复于 2006-03-13 15:50:10 得分 0
不过还是应该把sql语句放到外面比较合适Top
10 楼cyyno1(GunRose)回复于 2006-03-13 15:50:42 得分 0
temptid=""
For n=LBound(MyArray) To UBound(MyArray)-1
temptid=temptid&myarray(n)&"|"
Next
Conn.execute"update temp set temptid='"&temptid&"' where id="&i
response.write ""&temptid&""
这样写就可以了!Top
11 楼xscan(惊艳)回复于 2006-03-13 16:03:45 得分 0
我同意rainningsky() 的做法,事实证明也是对的,只是显示的时候有点问题,不过不要紧Top
12 楼cyyno1(GunRose)回复于 2006-03-13 16:18:59 得分 0
to:rainningsky()
为什么要增加数据库的负担呢?Top
13 楼starchange(星变_浙江教育学院)回复于 2006-03-13 18:10:56 得分 0
呵呵。上了车就想到这个初始化问题,可惜要1个多小时才到家。到了家赶紧看这个主题,结果。5555555……不但有很多人回答了。而且最主要的是我的一世英明啊。痛苦啊…………下次回答问题一定要看清楚。Top
14 楼taolidadi(桃李大地)回复于 2006-03-14 20:37:32 得分 0
呵呵,楼上的也不用哭啊,你在车上都能思考这个问题,说明你的收货比楼主还大也不一定啊,:),没有什么关系啦,程序本就是调试出来的嘛!Top




