You must Sign In to post a response.
  • Category: SQL Server

    Getting error how to clear it

    create procedure [dbo].[getregdetails]
    (
    @id int



    )
    as
    begin
    select * from registration
    end
    GO
    when i am executing above procesure error coming like below



    Procedure or function 'getregdetails' expects parameter '@id', which was not supplied.
    any one helpme
  • #752939
    hi

    you had created procedure with input parameters that's why the error, as it clearly indicating.

    You didn't used input parameter anywhere in procedure body, either you can create a procedure without a input parameter or else you must supply input parameter while executing like this


    exec getregdetails @id=12xx;

    Regards
    Sekhar Babu,
    www.aspdotnet-sekhar.blogspot.in

  • #752948
    if you need help while calling this procedure from the c# code using ado.net then please refer to below code where in I am creating SqlParameter object for @Id parameter and assigning it the value and adding this parameter to the sqlcommand object as shown below:

    SqlParameter param = new SqlParameter("@id", "1");
    SqlCommand cmd = new SqlCommand();
    cmd.CommandText = "dbo.getregdetails";
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(param);

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • #752953
    Hi,

    As per error details the input parameter whatever you declare that is not nullable field. So, you must and should use that, if you are not used then it will throw that error. If you want that is optional then declare as nullable field.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #761043
    Hi
    Rocky

    You can follow this steps you can solve your issue.



    Create table registration
    (
    Id int primary key identity(1,1),
    Ename varchar(30)
    )

    --Insert into registration values('AA1'),('AA2'),('AA3'),('AA4')



    Execute the Procedure


    create procedure [dbo].[getregdetails]
    (
    @id int
    )
    as
    begin
    select * from registration WHERE id=@id
    end
    GO

    exec [getregdetails] 1
    exec [getregdetails] 2

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments