sql SP



ALTER PROCEDURE arunsss 
    @suppid VARCHAR(50),
@suppname VARCHAR(50),
@dispname VARCHAR(50),
@exists bit  output
AS
SET @exists=0
BEGIN
    IF EXISTS (SELECT suppname from [supp] where suppname=@suppname)
    SET @exists=0
    ELSE
    BEGIN
    if(@suppid is null)
begin

 select @suppid= isnull(MAX(convert(int,suppid)),0)+1 from us.dbo.supp where ISNUMERIC (suppid)=1
end
INSERT INTO [us].[dbo].[supp]
           ([suppid]
           ,[suppname]
           ,[dispname])
     VALUES
           (@suppid,@suppname,@dispname)
      set @exists=1    
end
return @exists
END
GO


in code


  string connectionString = @"Server=AKBT-TM\SQL2008;Database=us;User ID=sa;Password=turner;";
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("dbo.arunsss"))
                {

                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();
                    cmd.Connection = conn;
                    SqlParameter sss=cmd.Parameters.Add("@exists",SqlDbType.Bit );
                    sss.Direction=ParameterDirection.Output;
                    cmd.Parameters.AddWithValue("@suppid", DBNull.Value);
                    cmd.Parameters.AddWithValue("@suppname", "sunils");
                    cmd.Parameters.AddWithValue("@dispname", "sunils");
                    cmd.ExecuteNonQuery();
                    if (sss.Value.ToString()=="false")
                    {

                    }
          }
}
Member Avatar for stbuchok

Can you explain your question in more detail and also explain where you are having issues?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.