Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C#
bal
public DataSet Fetch()
   {
       edal.connection();
       edal.sc.Open();
       ds = edal.Fill();
       edal.sc.Close();
       return ds;
   }

dal
public DataSet Fill()
    {
        SqlDataAdapter da = new SqlDataAdapter("masteriud", sc);
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        //SqlParameter param = new SqlParameter("@flag", 2);
        da.SelectCommand.Parameters.Add(new SqlParameter("@flag", SqlDbType.Int));
        da.SelectCommand.Parameters["@flag"].Value = 2;
        ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
ui
    public void fill()
    {
        ds = ebal.Fetch();
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }


Error - Procedure or Function 'masteriud' expects parameter '@Id', which was not supplied.

i dont want to use any parameter i just want to show data on page load using flag
my store procedure goes like this

SQL
alter procedure masteriud(@Id int,@Name varchar(50),@Address varchar(50),@flag int)
as
begin
if @flag='1'
begin
insert into Memployee(Id,Name,Address)values(@Id,@Name,@Address)
end

if @flag='2'
begin
select * from Memployee
end


Please help me out in this coding
Thanks!!! :)
Posted

i dont want to use any parameter i just want to show data on page load using flag
Error - Procedure or Function 'masteriud' expects parameter '@Id', which was not supplied.
2 things:
1. Either pass on all the 4 parameters to make it work - Id, Name, Address & flag
2. Or, change your SP to just expect 1 parameter flag as per you want and then form the needed query just using it as you want to.

Try!
 
Share this answer
 
Comments
Harsha Dev 14-Jun-12 0:33am    
thanks man i will try...
Dear Harsha,

you seriously misunderstood "the tier thing". Here you can find a simple example of how something similar can be done.

http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764584642,descCd-DOWNLOAD.html[^]
http://thebeerhouse.codeplex.com/[^]
http://www.asp.net/web-forms/tutorials[^]

Check these pages out, you will find working examples which will help you understand the basic concepts and show you some nice tricks.


Cheers
 
Share this answer
 
Comments
Harsha Dev 14-Jun-12 0:36am    
thank you so much sir...will learn from these links :)
i am a fresher :(:)
hi friend you are sending only flag on this procedure through your code lets try this
alter procedure masteriud(@flag int)
as
begin
if (@flag==1)
begin
insert into Memployee(Id,Name,Address)values(@Id,@Name,@Address)
end

else if (@flag==2)
begin
select * from Memployee
end
end
it will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900