473,473 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

formview insert identity?

I'm trying to retrieve the @@identity value of the just-inserted record using
a FormView control on an .aspx page. Here's what I have tried.....
--change in-line Insert in the SqlDataSource from Text to Stored Procedure
--added Insert parameter "AdrID" direction:output to the SqlDataSource
--added "AdrId" as an OUT parameter in the Stored Procedure
--try to retrieve the "AdrId" in the Inserted Event handler of the
SqlDataSource

The new record is successfully inserted, but I'm still getting an error:
"An SqlParameter with ParameterName '@AdrID' is not contained by this
SqlParameterCollection."

Relevant coding:

from MaintAdrDetail.aspx....

<asp:SqlDataSource ID="AdrDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:LWIF_SQLConnectionString %>"
InsertCommand="AdrInsert" InsertCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
<InsertParameters>
<asp:Parameter Name="@AdrID" Type=Int32 Direction=Output />
</InsertParameters>

from AdrInsert stored procedure....

ALTER PROCEDURE dbo.AdrInsert

@AdrFirstName nvarchar(25),
@AdrLastName nvarchar(50),
[clip]
@AdrOwnerID nvarchar(4),
@AdrNote nvarchar(MAX),
@AdrID int=0 OUTPUT
AS
INSERT INTO Addresses
(
[AdrFirstName],
[AdrLastName],
[clip]
[AdrOwnerID],
[AdrNote]
)
VALUES
(
@AdrFirstName,
@AdrLastName,
[clip]
@AdrOwnerID,
@AdrNote
);
SELECT @AdrID = @@IDENTITY

From MainAdrDetail.aspx.vb

Protected Sub AdrDataSource_Inserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.SqlDataSourceStatusEvent Args) Handles
AdrDataSource.Inserted
Session("AdrSelected") =
e.Command.Parameters("@AdrID").Value.ToString()
End Sub
Jan 28 '07 #1
0 1563

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Sikorsky | last post by:
Using: MS SQL Server 2005 Sept 05 CTP, MS Visual Studio 2005 Beta 2 How can I get the SQL Server Row ID of the newly inserted row when adding a new record to the database using a FormView Control...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
2
by: sck10 | last post by:
Hello, I have a LinkButton that I use to open a FormView in ReadOnly mode "ShowList", and a LinkButton to open the same FormView in the Insert mode "NewRecord". If the user clicks "ShowList"...
1
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
0
by: hardieca | last post by:
Hi, My formview or gridview control stops updating or deleting a record once the record has a null value. I have table tblTest with the following pkID int NOT NULL **IDENTITY COLUMN**...
1
by: d-42 | last post by:
Hi, I'm trying to use FormView to Insert an Object to an ObjectDataSource. The insert method signature is simply: void DALObject.InsertPerson(Person myObject) The person object for the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.