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
 Syntax problems

Author  Topic 

stuckne1
Starting Member

22 Posts

Posted - 2009-06-22 : 10:23:17
Hi i'm trying to do this...except with a stored procedure.

(c# code)
sqlCommand myDeleteCommand = new sqlCommand("DELETE FROM userTable WHERE autoIncrementID=" + ListBox1.SelectedValue, connection);
myDeleteCommand.ExecuteNonQuery();

(attempted procedure at the moment)
USE [FinAid_Report_Form]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE P_sp_DeleteAdmin
-- 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 adminTable
Where autoIncrementID=
END
GO

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-22 : 10:24:57
should be this

CREATE PROCEDURE P_sp_DeleteAdmin
-- 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 adminTable
Where autoIncrementID=@autoIncrementID
END
GO

also you should pass the parameter value from application
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-22 : 10:32:52
quote:
Originally posted by visakh16

should be this

CREATE PROCEDURE P_sp_DeleteAdmin
-- 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 adminTable
Where autoIncrementID=@autoIncrementID
END
GO

also you should pass the parameter value from application


What is this comma?
(red and underlined)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

stuckne1
Starting Member

22 Posts

Posted - 2009-06-22 : 10:37:42
That comma is why I just spent 5 minutes wondering why I couldn't get it to work, but since you pointed it out I got rid of it. Thank you very for the responses, I have it working now.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-22 : 10:54:39
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -