J
Jan Hendrickx
Hi all,
I use (something like) following code to add new records to a database,
but it doesn't work!!!
I need to know the value of an AutoNumber-field when I add the record.
Why doesn't it work and how can I make it work???
I think it should be easy, but I can't figure it out!
Thanks in advance...
Jan H.
<%option explicit
dim cn, rs, v1, v2, v3
set cn=server.createobject("ADODB.Connection")
set rs=server.createobject("ADODB.Recordset")
cn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
server.mappath("./mdb/MyMDB.mdb")
rs.open "SELECT * FROM tblTest",cn,3,3
rs.addnew
rs("Naam")="Some new value"
v1=rs("ID")
rs.update
v2=rs("ID")
rs.moveprevious 'this works,
rs.movenext 'but only when
v3=rs("ID") 'not first record!!!!
rs.close
cn.close
set rs=nothing
set cn=nothing%>
<html>
</head>
<body>
*** <%=v1%> *** <%=v2%> *** <%=v3%> ***
</body>
</html>
I use (something like) following code to add new records to a database,
but it doesn't work!!!
I need to know the value of an AutoNumber-field when I add the record.
Why doesn't it work and how can I make it work???
I think it should be easy, but I can't figure it out!
Thanks in advance...
Jan H.
<%option explicit
dim cn, rs, v1, v2, v3
set cn=server.createobject("ADODB.Connection")
set rs=server.createobject("ADODB.Recordset")
cn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
server.mappath("./mdb/MyMDB.mdb")
rs.open "SELECT * FROM tblTest",cn,3,3
rs.addnew
rs("Naam")="Some new value"
v1=rs("ID")
rs.update
v2=rs("ID")
rs.moveprevious 'this works,
rs.movenext 'but only when
v3=rs("ID") 'not first record!!!!
rs.close
cn.close
set rs=nothing
set cn=nothing%>
<html>
</head>
<body>
*** <%=v1%> *** <%=v2%> *** <%=v3%> ***
</body>
</html>