Sunday, March 25, 2012

Aaargh! Storedproc vs SQL in Gridview update

When I attempt to update using a stored procedure I get the error 'Incorrect syntax near sp_upd_Track_1'. The stored procedure looks like the following when modified in SQLServer:

ALTERPROCEDURE [dbo].[sp_upd_CDTrack_1]

(@.CDTrackNamenvarchar(50),

@.CDArtistKeysmallint,

@.CDTitleKeysmallint,

@.CDTrackKeysmallint)

AS

BEGIN

SETNOCOUNTON;

UPDATE [Demo1].[dbo].[CDTrack]

SET [CDTrack].[CDTrackName]= @.CDTrackName

WHERE [CDTrack].[CDArtistKey]= @.CDArtistKey

AND [CDTrack].[CDTitleKey]= @.CDTitleKey

AND [CDTrack].[CDTrackKey]= @.CDTrackKey

END

But when I use the following SQL coded in the gridview updatecommand it works:

"UPDATE [Demo1].[dbo].[CDTrack]

SET [CDTrack].[CDTrackName] = @.CDTrackName

WHERE [CDTrack].[CDArtistKey] = @.CDArtistKey

AND [CDTrack].[CDTitleKey] = @.CDTitleKey

AND [CDTrack].[CDTrackKey] = @.CDTrackKey"

Whats the difference? The storedproc executes ok in sql server and I guess that as the SQL version works all of my databinds are correct. Any ideas, thanks, James.

Not sure if it's the source of your problem, but shouldn't sp_upd_Track_1 and p_upd_CDTrack_1 be the same or was that a typo?

|||Yeah, typo, the correct name is specified in the storedproc and referenced correctly in the asp.

No comments:

Post a Comment