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.
| 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 ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE P_sp_DeleteAdmin -- Add the parameters for the stored procedure here @autoIncrementID, intASBEGIN -- 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=ENDGO |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-22 : 10:24:57
|
should be thisCREATE PROCEDURE P_sp_DeleteAdmin-- Add the parameters for the stored procedure here@autoIncrementID, intASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereDelete From adminTableWhere autoIncrementID=@autoIncrementIDENDGO also you should pass the parameter value from application |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-22 : 10:32:52
|
quote: Originally posted by visakh16 should be thisCREATE PROCEDURE P_sp_DeleteAdmin-- Add the parameters for the stored procedure here@autoIncrementID, intASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereDelete From adminTableWhere autoIncrementID=@autoIncrementIDENDGO 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. |
 |
|
|
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. |
 |
|
|
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. |
 |
|
|
|
|
|