J
|
Jane 8/31/2006 |
Hi, Sub AfterAdd() str = "select @@identity" Set rsTemp = server.CreateObject("ADODB.Recordset") rsTemp.open str, dbConnection %><script language="JavaScript"> alert("you added a new record with id=<%=rsTemp(0)%>"); </script> <% End Sub |
R
|
rgke author 9/2/2006 |
OK thanks, this is excellent. If I wanted to display something other than the primary key (as well), I thought I could modify the line as follows (where ProjMainKey is a field in the recordset). |
J
|
Jane 9/4/2006 |
Hi, Sub AfterAdd() 'select id of last inserted record str = "select @@identity" Set rsTemp = server.CreateObject("ADODB.Recordset") rsTemp.open str, dbConnection 'select other info of last inserted record str1 = "select * from TableName where ID=" & rsTemp(0) Set rsTemp1 = server.CreateObject("ADODB.Recordset") rsTemp1.open str1, dbConnection %><script language="JavaScript"> alert("you added a new record with id=<%=rsTemp(0)%>, ProjKeyMain=<%=rsTemp1("ProjKeyMain")%>"); </script> <% End Sub
|
R
|
rgke author 9/4/2006 |
OK, now this sort of works, except that rstemp(0) returns nothing, so I end up with a syntax error. If I replace rstemp(0) with an actual value hardcoded, it is fine, os obviosly rstemp(0) is not producing any results. |
R
|
rgke author 9/6/2006 |
OK, now this sort of works, except that rstemp(0) returns nothing, so I end up with a syntax error. If I replace rstemp(0) with an actual value hardcoded, it is fine, os obviosly rstemp(0) is not producing any results. |
J
|
Jane 9/6/2006 |
This code works fine on my test box. |