CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Get idenity column value

Print topic Send  topic

Author Message
alexands

Posts: 11
Posted: 11/07/2006, 12:51 PM

Hi,

I have a record form where I am inserting values into my table. My table (MSSQL) has an identity column. How can I retreive the identity value of the record I just inserted. I have seen a few posts that somewhat "describe" what to do, but I have yet to see anything that shows specifically what code to create and where to create it. I'm using C#.

Thanks,
Scott
View profile  Send private message
Edd


Posts: 547
Posted: 11/08/2006, 4:06 AM

Try

Getting the @@IDENTITY from SQL. This must be performed IMMEDIATELY after the insert before the connection is closed - otherwise the information is lost.

Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message
alexands

Posts: 11
Posted: 11/10/2006, 10:12 AM

Edd,

Thanks for the tip. I figured this is what I needed to do. However, because I am not familiar with the data object model of CCS, can you provide a specific code example?

Thanks,
Scott
View profile  Send private message
peterr


Posts: 5971
Posted: 11/10/2006, 11:01 AM

Scott,
The "Multi-step Registration" example in CCS Example Pack has working example of this specific functionality (only @@IDENTITY is replaced there with non database specific SQL).
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
JayEdgar


Posts: 77
Posted: 11/16/2006, 7:37 PM

There is an exception to this: If you have triggers running in SQL Server. In this case, it will return the identity of the record changed as a result of the trigger, not your change. In this case, I often write a unique value to an unused/lesser-used field, then search for that value after the insert, get the PK and clear the temp field.

99.9% of people won't need to know this, and for that .1% person who does, cheers,

Jay
View profile  Send private message

Add new topic Subscribe to topic   


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

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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