CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 Just inserted record

Print topic Send  topic

Author Message
Charl Du Toit
Posted: 12/11/2002, 9:19 PM

Hi all

How do you find the record that was just inserted.

ASP & Access

Charl

Vic
Posted: 12/11/2002, 11:35 PM

Hi,

Used AfterExecuteInsert() event with custom code like :
Dim rs
Set rs = Your_DB.Execute("SELECT @@IDENTITY FROM Your_table")
If Not rs.EOF Then
Response.write "id=" & rs(0)
End If
Set rs = Nothing

Vic

Charl Du Toit
Posted: 12/12/2002, 3:06 AM

you cant do this with MS Access. It doenst seem to support it . is there any
other way of doing it ??

Regards

"Vic" <victor.tciba@yessoftware.com> wrote in message
news:at9e7l$4qi$1@news.codecharge.com...
> Hi,
>
> Used AfterExecuteInsert() event with custom code like :
> Dim rs
> Set rs = Your_DB.Execute("SELECT @@IDENTITY FROM Your_table")
> If Not rs.EOF Then
> Response.write "id=" & rs(0)
> End If
> Set rs = Nothing
>
> Vic
>
>

Vic
Posted: 12/12/2002, 6:12 AM

Try

GetLastKey = CCDLookup("max(" & your_key_field & ")",
your_table_name,your_where,Your_DB)
where your_where can be ="" or ="user_id=777" or .....

Vic

BJ Freeman
Posted: 12/21/2002, 10:50 AM

just after the insert do something similar to this

SELECT TableIDField FROM TABLE WHERE Field='Field Value Inserted'


"Charl Du Toit" <charl@dkalmin.co.za> wrote in message
news:at969q$mr7$1@news.codecharge.com...
> Hi all
>
> How do you find the record that was just inserted.
>
> ASP & Access
>
> Charl
>
>

Sixto Luis Santos
Posted: 12/22/2002, 8:48 PM


It should work. Try this:

Add the following code in the After Execute Insert event of your record
form:

'----------------------------
dim identity
identity=CCDLookUp("@@Identity", "", "", DByour_db_connection_name)

Response.Write "LAST ID: " & identity
Response.End
'----------------------------

Remember to replace your_db_connection_name with the actual name as used by
your application (with the letters DB prefixed). Now, after creating your
custom event, get to the live page and insert some new data.

Right after inserting new data, your application should stop and a single
line (LAST ID: ##) should appear in your browser.

The trick is, first to use ADO v2.5 or better, and second, to get the
identity using the same db connection used to insert the data. If you try to
use another connection, @@identity returns 0. Also, don't specify a table
with @@Identity.

The @@Identity is supported thru OLEDB. Access 2000 supports @@Identity
natively, and the restriction to use the same connection does not apply
(just like using @@Identity in SQL Server).

By the way, the example code provided is equivalent to what Vic suggested,
but using the CCS functions, and without specifying the table.

Regards,

Sixto

"Charl Du Toit" <charl@dkalmin.co.za> wrote in message
news:at9qjt$rrn$1@news.codecharge.com...
> you cant do this with MS Access. It doenst seem to support it . is there
any
> other way of doing it ??
>
> Regards
>
> "Vic" <victor.tciba@yessoftware.com> wrote in message
>news:at9e7l$4qi$1@news.codecharge.com...
> > Hi,
> >
> > Used AfterExecuteInsert() event with custom code like :
> > Dim rs
> > Set rs = Your_DB.Execute("SELECT @@IDENTITY FROM Your_table")
> > If Not rs.EOF Then
> > Response.write "id=" & rs(0)
> > End If
> > Set rs = Nothing
> >
> > Vic
> >
> >
>
>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.