–Stored procedure
ALTER PROCEDURE [dbo].[Test]
@USERID varchar(25)
AS
BEGIN
SET NOCOUNT ON
IF NOT EXISTS Select * from Users where USERID = @USERID)
BEGIN
INSERT INTO Users (USERID,HOURS) Values(@USERID, 0);
END
I have this stored procedure in sql server 2005 and want to pass userid from a C# application. How can I do that. Many Thanks.
This topic is extensively covered in MSDN here. See the section entitled “Using Parameters with a SqlCommand and a Stored Procedure” for a nice sample: