Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 stored procedure not working

Author  Topic 

stuckne1
Starting Member

22 Posts

Posted - 2009-06-22 : 13:25:18
USE [FinAid_Report_Form]
GO
/****** Object: StoredProcedure [dbo].[P_sp_DeleteUser] Script Date: 06/22/2009 11:55:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[P_sp_DeleteUser]
-- Add the parameters for the stored procedure here
@autoIncrementID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
Delete From userTable
Where autoIncrementID = @autoIncrementID
END


here is the c# code
I tried it both ways...
SqlCommand myDeleteCommand = new SqlCommand("P_sp_DeleteUser", connection);
myDeleteCommand.Add("@autoIncrementID", Convert.ToInt32(ListBox1.SelectedValue));
myDeleteCommand.ExecuteNonQuery();

and tried like these ways too
myDeleteCommand.Add("@autoIncrementID",ListBox1.SelectedValue);
myDeleteCommand.AddWithValue("autoIncrementID", ListBox1.SelectedValue);
myDeleteCommand.addWithValue("autoIncrementID", Convert.ToInt32(ListBox1.SelectedValue));

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-22 : 13:31:19
http://support.microsoft.com/kb/320916
Go to Top of Page

stuckne1
Starting Member

22 Posts

Posted - 2009-06-22 : 15:25:07
Alright I got it. Thanks for the link.
Go to Top of Page
   

- Advertisement -