Hi, thanks for the response.
I have a storedprocedure as follows...
ALTER PROCEDURE [dbo].[MyProc]
(
@ID int = NULL OUTPUT,
@Name varchar(50)
)
AS
SET NOCOUNT ON
DECLARE @Result int
BEGIN TRANSACTION
IF EXISTS
(
SELECT
1
FROM [MyTable] WITH (UPDLOCK)
WHERE [Name] = @Name
)
BEGIN
SELECT @Result = -1
END
ELSE
BEGIN
INSERT INTO [MyTable]
(
[Name]
)
VALUES
(
@Name
)
SELECT @ID = SCOPE_IDENTITY();
END
IF @Result <> 0
BEGIN
ROLLBACK
END
ELSE
BEGIN
COMMIT
END
RETURN @Result
If the field "Name" already exists in the database it will return -1. Then I am running the following code...
1 protected void MyDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e)
2 {
3 if ((Int32)e.Command.Parameters["@Result"].Value == -1)
4 {
5 Label1.Text = "Record Exists.";
6 // Populate submitted fields with relevant values
7 }
8 else
9 {
10 Label1.Text = "Insert Complete.";
11 }
12 }
So at line six I am trying to populate the previously submitted with the relevant values. That's where you insert the code from my previous post, replaces the MyBool with line 3 from above.
Does that help?
Thanks again.