-1

I am trying to update/ delete data from database using grid view but i am receiving this error.i use this query to show grid view like this :

SELECT ST_Anouncement.An_Id AS AnnouncementNumber, 
       Course.CourseName + ' ' + Class.Semester + ' ' 
       + Class.Section + ' ' + Class.Session AS Class, 
       ST_Anouncement.Description 
FROM ST_Anouncement 
     INNER JOIN Class ON ST_Anouncement.Class_Id = Class.Class_Id 
     INNER JOIN Course ON Class.CourseId = Course.CourseId    

enter image description here

While my update stored procedure is :

[ALTER PROCEDURE [dbo].[sp_ap_Announcement_update]

@Class_Id int,
@Description nvarchar(250)

AS
BEGIN
    UPDATE [dbo].[ST_Anouncement]
   SET [Class_Id] = @Class_Id
      ,[Description] = @Description
 WHERE Class_Id = @Class_Id


END
]

Tell me how i can solve this issue. I am using entityframe work in asp.net

Tanner
  • 22,205
  • 9
  • 65
  • 83
Syed Usama
  • 1
  • 1
  • 6
  • you should avoid using the `sp_` prefix for stored procedures, see: http://stackoverflow.com/a/238394/57475 – Tanner Sep 14 '15 at 11:12
  • Firstly, Your posted question says **sp_ap_Announcement_delete** has too many argument specified but you haven't shared us the stored procedure for **delete** functionality and the how you are calling this stored procedure in .cs file. Kindly share them too that would be much more helpful. – Suprabhat Biswal Sep 14 '15 at 11:21

1 Answers1

0

You don't have to update the Class_Id field

Following UPDATE statement is enough

UPDATE [dbo].[ST_Anouncement]
SET 
    [Description] = @Description
WHERE Class_Id = @Class_Id

By the way this is the UPDATE stored procedure, but the error is caused by DELETE procedure

Do you have codes for it? It should be similar to below with the PK for the table instead of Class_Id field

ALTER PROCEDURE [dbo].[sp_ap_Announcement_delete]
@Class_Id int
AS
BEGIN
    DELETE FROM [dbo].[ST_Anouncement]
    WHERE Class_Id = @Class_Id
END
Eralper
  • 6,461
  • 2
  • 21
  • 27