Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 27th, 2007, 04:57 PM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Edit record right after it was Inserted?

I know how to do what I need using classic ASP-style coding even in C#. But hoe to achieve the same result with less coding with help of ASP.NET gadgets?

I have form like
<form id="form1" runat="server" ...
and
<asp:SqlDataSource ID="SqlDataSource1" runat="server"...

Problem! How after Insert remain on this inserted record to Edit it?

Maybe lesser problem: how to get unique ID of inserted record? Please don't offer just to select max ID because this is not a correct answer for multiuser app.



  #2 (permalink)  
Old November 27th, 2007, 11:39 PM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Give identity facility Then
In the insert procedure set an output parameter and after insert command
outputparameter=@@identity

  #3 (permalink)  
Old November 28th, 2007, 07:32 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To get the unique Id use identity column and in the SP use scope_identity().

Sony
  #4 (permalink)  
Old November 30th, 2007, 11:48 AM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by AnjuSujith
 Give identity facility Then
In the insert procedure set an output parameter and after insert command
outputparameter=@@identity
And how do I do that using

<asp:SqlDataSource ID="SqlDataSource1" runat="server"...

?

  #5 (permalink)  
Old December 11th, 2007, 03:18 PM
Friend of Wrox
 
Join Date: May 2006
Location: Northampton, United Kingdom.
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

What the others are saying is that the easiest way is to use a stored procedure to actually insert the record.

Within the stored procedure you can declare a value which can be returned to the asp code

eg Declare @ReturnScope as int

After you have performed the record insertion then in this returned value you place the value in scope_identity()

eg Set @ReturnScope = scope_identity()

Return scope_identity()


When you get back to the asp code then you can use this value to do whatever you want with it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get last inserted record in a table?? dayaananthanm SQL Server 2005 6 June 11th, 2007 09:15 PM
Record is Inserted Twice donevco Access 1 February 27th, 2007 12:28 PM
Return to Inserted Record - FormView rit01 ASP.NET 2.0 Basics 15 January 27th, 2007 12:04 PM
how to avoid edit of inserted data in Excel? kotaiah Excel VBA 3 September 14th, 2006 01:49 AM
Last record inserted ID ADAC Programming VB Databases Basics 1 June 5th, 2006 02:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.