Updating records using stored procedure in sqldatasource?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

Up vote 2 down vote favorite share g+ share fb share tw.

I have datasource which has an sp called for update and been binded to gridview. I want while updating it should use the sp and update table. Below is my design code.

'> '> '> ' Enabled="false" /> ' Enabled="true" /> '> ' /> " SelectCommand= "SELECT TITLE, QUOTE, QUOTELINK, PUBLISHED, PUBLISHEDDATE FROM DBO. QUOTES" UpdateCommand="sp_ModifyQuotes" UpdateCommandType="StoredProcedure"> and below is my SP ALTER PROCEDURE dbo. Sp_ModifyQuotes @Title varchar(max), @Quote varchar(max), @QuoteLink varchar(max), @Published Bit, @PublishDate DateTime, @Modify varchar(10) AS BEGIN Declare @QuoteId int IF (@Modify = 'Add') BEGIN INSERT INTO dbo.

QUOTES ( Title, Quote, QuoteLink, Published, PublishedDate ) values ( @Title, @Quote, @QuoteLink, @Published, @PublishDate ) SET @QuoteId = @@IDENTITY If @Published = 1 BEGIN UPDATE dbo. Quotes SET Published = 0 WHERE Id @QuoteId AND Published = 1 END --SELECT @QuoteId As ID END ELSE IF (@Modify = 'Update') BEGIN UPDATE dbo. Quotes SET Quote = @Quote, QuoteLink = @QuoteLink, Published = @Published, PublishedDate = @PublishDate WHERE Title = @Title --SELECT '1' As ID END ELSE IF (@Modify = 'Delete') BEGIN DELETE FROM dbo.

Quotes WHERE Title = @Title --SELECT '1' As ID END END please any one help me how should I update my records when I try to update I gets an error saying: Procedure or function sp_ModifyQuotes has too many arguments specified. But I guess I have passed all proper parameters. Asp.net sql-server-2008 update sqldatasource link|improve this question edited May 20 '11 at 15:55Ken Pespisa8,57911428 asked May 20 '11 at 15:51Abbas345221 71% accept rate.

That might give you an idea of where the extra parameter is coming from... – pseudocoder May 20 '11 at 16:09.

The Modify parameter is in the INSERT/VALUES parts of your SP - basically they do not match.

IrishChieftain: I created new SP, dedicated for update but still same issue: here's new SP CREATE PROCEDURE sp_UpdateQuotes @Title varchar(max), @Quote varchar(max), @QuoteLink varchar(max), @Published Bit, @PublishDate DateTime AS BEGIN UPDATE dbo. Quotes SET Quote = @Quote, QuoteLink = @QuoteLink, Published = @Published, PublishedDate = @PublishDate WHERE Title = @Title If @Published = 1 BEGIN UPDATE dbo. Quotes SET Published = 0 WHERE Title @Title AND Published = 1 END END GO – Abbas May 20 '11 at 16:17 Make sure your new parameter list matches those in the list - check the types as well; everything has to match – IrishChieftain May 20 '11 at 16:27 @IrishChieftain: It seems that was working fine on my local PC, but when I uploaded the same on my server, update button just does not works.. this had put me in trouble... Please help me out for this, the code, database, tables, sp's, everything is same – Abbas May 20 '11 at 19:13 Is there an error message?

Comment out any try/catches you have and see what it reports. Execute the stored procedure in SQL Server Management Studio to rule that out... do you have a staging server? – IrishChieftain May 20 '11 at 19:17 @IrishChieftain: I have a staging server, I am using dotnetnuke on that, on the site without dotnetnuke runs fine, even on stage, but on the same server, everything is same, just it has dotnetnuke installed, there I am unable to update, there is just no error, not even the button event is executed.

I even tried using oncommand event and placed response message, but that too not working, because its not going inside the button events, don't know whats happening. – Abbas May 20 '11 at 19:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions