This topic has been archived. It cannot be replied.
-
工作学习 / IT杂谈 / ASP question please help!! thanks!!
-fengvan(Sunny);
2002-3-20
{517}
(#411681@0)
-
你update之后,再retrieve rs(0)的值为多少?
-mcdonald(麦当劳);
2002-3-20
(#411710@0)
-
this is the program look like after i change. but It still does not work.this is the look after i change.
It still does not work.
please show me how! thank you!!
sql="select * from studentinfor"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,connstr,3,2
rs.addnew
rs(1)="123"
rs(2)="abc"
rs.update
rs(3)="picture_" & rs(0) (but the rs(3) get nothing, why i can not get rs(0) value )
rs.update
rs.close
set rs = nothing
-fengvan(Sunny);
2002-3-20
{404}
(#411726@0)
-
不好意思,我没用过ASP.帮你up一下.看你的code,update之后,你在用一次selec to get the value of rs(0), i think you may not be able to get the rs(0) value before you write it back to database.
-mcdonald(麦当劳);
2002-3-20
(#411746@0)
-
你这样试试看sql="select * from studentinfor"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,connstr,3,2
rs.movelast
id=rs(0)+1
rs.addnew ( rs(0) is an auto number from 1, step is 1 )
rs(1)="123"
rs(2)="abc"
rs(3)="picture_" &id (but the rs(3) get nothing, why i can not get rs(0) value )
(rs(3) photo file)
rs.update
rs.close
set rs = nothing
-kevin_tor(晚睡晚起的懒猫);
2002-3-20
{381}
(#411801@0)
-
one person use ok, but if many people add new date at same time. it may have problem
-fengvan(Sunny);
2002-3-20
(#411866@0)
-
try thissql="select * from studentinfor"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,connstr,2,3 (this line has been modified)
rs.addnew
rs(1)="123"
rs(2)="abc"
rs.update
rs(3)="picture_" & rs(0)
rs.update
rs.close
set rs = nothing
'not tested...
-nice2002(nice2002);
2002-3-20
{287}
(#411818@0)
-
should add
rs.movelast
between
rs.update and rd(3)="picture"&rs(0)
-nice2002(nice2002);
2002-3-20
(#411837@0)
-
not work !!
-fengvan(Sunny);
2002-3-20
(#411873@0)
-
well tested...working finesql="select * from studentinfor order by (your auto id field name)"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,connstr,2,3 (this line has been modified)
rs.addnew
rs(1)="123"
rs(2)="abc"
rs.update
rs.movelast
temp=rs(0)
rs(3)="picture_" & temp
rs.update
rs.close
set rs = nothing
-nice2002(nice2002);
2002-3-21
{330}
(#413151@0)
-
你这个是不保险的。你用lock了没有?什么模式的recordset?如果在你update和movelast之间有另外一个人也作了insert,那么你得到的是谁的new ID? That's why I said we should use trigger.
-luoboyang(萝卜秧);
2002-3-21
(#413167@0)
-
I agree !
-fengvan(Sunny);
2002-3-21
(#413192@0)
-
ok,you are right,change to
rs.open sql,connstr,2,2---------2 means recoed locked before and after you edit utill you destroy the recordset
-nice2002(nice2002);
2002-3-21
(#413239@0)
-
by the way,what is the version of ASP?if you have 3.0(win2000),i will give you better code
-nice2002(nice2002);
2002-3-21
(#413245@0)
-
ASP 3。0
-fengvan(Sunny);
2002-3-21
(#413255@0)
-
here you go....sql="select * from studentinfor"
Set rs = Server.CreateObject("ADODB.Recordset")
with rs
.open sql,connstr,2,2
.addnew
.fields(1)="123"
.fields(2)="abc"
.update
temp=.fields(0)
.fields(3)="picture_" & temp
.update
END with
..............
not tested,you may test again
-nice2002(nice2002);
2002-3-21
{366}
(#413405@0)
-
这样试试AutoID时数据存到数据库的时候自动产生的,你这样是取不到值的
你这样试
.................
sql="select * from studentinfor"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,connstr,3,2
rs.movelastrecord(这句话你自己去看help,我记得不是太清楚)
ID=int(trim(rs(0)))+1
rs.addnew
rs(1)="123"
rs(2)="abc"
rs(3)="picture_" & cstr(id)
rs.update
rs.close
set rs = nothing
.....................
How should i do to get the rs(0) value?
-kevin_tor(晚睡晚起的懒猫);
2002-3-20
{480}
(#411825@0)
-
你是想要获得 identity field 的自增值, 然后用在下一条record?
如果条件容许, you can use "store procedure", plus "command" object
使用 global variable "@@identity "
-fxue(fxue);
2002-3-21
(#412653@0)
-
我是想要获得 identity field 的自增值, 然后用在本条record
-fengvan(Sunny);
2002-3-21
(#412751@0)
-
看我下面的贴子,这样的话,你就要用trigger了。
-luoboyang(萝卜秧);
2002-3-21
(#412753@0)
-
我的小字报:
-luoboyang(萝卜秧);
2002-3-21
{940}
(#412738@0)
-
谢谢!!!
-fengvan(Sunny);
2002-3-21
(#412757@0)
-
Depend on different databaseIf Access or Ms SQL
right after insert query, run SELECT @@identity to get the autoinc field's value.
If Oracle or Interbase, directly get the value from
sequence or generator
-jchonc(James);
2002-3-22
{182}
(#414749@0)