Stored proc call - passing a parameter [modified]
-
I have an app with a DAL and so far I have been calling sprocs that require no input parameters and all works fine. I now have to call a sproc with requires an input paramter. The sproc I am calling is as follows: ALTER PROCEDURE dbo.prc_QA_SysCodes_sel_drop_fill ( @sysCodeType as int ) As BEGIN DECLARE @Err Int SELECT A.[SysCodeID], A.[SysCodeDesc] FROM [Contract].[dbo].[QA_SysCodes] A WHERE A.SysCodeType = @sysCodeType order by A.[SortOrder], A.[SysCodeID] Set @Err = @@Error RETURN @Err End I need to pass in the @sysCodeType but can't figure out how to pass it to the sproc. Thoughts, words of wisdom? -- modified at 13:16 Tuesday 27th June, 2006
-
I have an app with a DAL and so far I have been calling sprocs that require no input parameters and all works fine. I now have to call a sproc with requires an input paramter. The sproc I am calling is as follows: ALTER PROCEDURE dbo.prc_QA_SysCodes_sel_drop_fill ( @sysCodeType as int ) As BEGIN DECLARE @Err Int SELECT A.[SysCodeID], A.[SysCodeDesc] FROM [Contract].[dbo].[QA_SysCodes] A WHERE A.SysCodeType = @sysCodeType order by A.[SortOrder], A.[SysCodeID] Set @Err = @@Error RETURN @Err End I need to pass in the @sysCodeType but can't figure out how to pass it to the sproc. Thoughts, words of wisdom? -- modified at 13:16 Tuesday 27th June, 2006
Add parameter to your procedure:
yourSP.Parameters.Add(ParamName, SqlParamType, length); //length is optional
Pass value to the paramyourSP.Parameters[ParamName].Value = ParamValue;
Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O