Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Another beginner question on updating data with MM .NET
Message
From
27/06/2008 17:32:14
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Another beginner question on updating data with MM .NET
Miscellaneous
Thread ID:
01327386
Message ID:
01327386
Views:
66
Hi again.

I am sure this is covered in the documentation, but I can't seem to see it this afternoon.

I am a simple 2 column child table related to a parent table. The tables primary key is comprised of the 2 columns

Column 1 -> TheFK
Column 2 -> Name

Primary key -> TheFK+Name

The BLG creates an update SP something like this:
CREATE PROCEDURE [dbo].[LstUpdate]
(
	@TheFK int,
	@Name char(20)
	
)
AS
	SET NOCOUNT OFF;
	UPDATE [dbo].[TheTable]
	SET 
		[Name] = @Name,
		[TheFK] = @TheFK
		 
	WHERE 
	(
		([Name] = @Name) AND 
		([TheFK] = @TheFK)
		
	);
	
	SELECT 
		[Name], 
		[TheFK]
	FROM [dbo].[TheTable]
	WHERE
		([TheFK] = @TheFK) AND 
		([Name] = @Name)
Of course this will not work.

The update SP needs to look something like this:
CREATE PROCEDURE [dbo].[LstUpdate]
(
	@TheFK int,
	@OldName char(20),
         @NewName char(20)
	
)
AS
	SET NOCOUNT OFF;
	UPDATE [dbo].[TheTable]
	SET 
		[Name] = @NewName,
		[TheFK] = @TheFK
		 
	WHERE 
	(
		([Name] = @OldName) AND 
		([TheFK] = @TheFK)
		
	);
	
	SELECT 
		[Name], 
		[TheFK]
	FROM [dbo].[TheTable]
	WHERE
		([TheFK] = @TheFK) AND 
		([Name] = @NewName)
I understand how to fix the procedure and I can modify or override the CreateUpdateCommand factory method. My question is what methods do I need to override so that I can pass the orginal row value for the @OldName parameter?

Thanks for all your help.

Best regards,

Tim Holgerson
Next
Reply
Map
View

Click here to load this message in the networking platform