Click here to Skip to main content
15,885,827 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hello,

While I am running my code i got following problem...

code are

C#
public DataTable GetAllById(string Did)
    {
        DataTable tableMpr=null;
        id=new Guid(Did.ToString ()); 
        con.Open();
        DataSet ds = new DataSet();                      
        SqlDataAdapter sda = new SqlDataAdapter("uuspGetAllMprOneById", con);
        sda.SelectCommand.Parameters.Add(new SqlParameter("@Id",          SqlDbType.UniqueIdentifier));
        sda.SelectCommand.Parameters["@Id"].Value = id;
        sda.Fill(ds);
        tableMpr = ds.Tables[0];
        con.Close();
        return tableMpr;
}

and My stored procedure is

SQL
alter PROCEDURE [dbo].[uuspGetAllById]
    @ID uniqueidentifier
AS
SET NOCOUNT ON
Select * from mUsers where DId=@ID

return


While Running this Code I got following error..

Procedure or function 'uuspGetAllById' expects parameter '@ID', which was not supplied.

I don't know where i am lacking

Thnak's in advance..
Posted
Updated 11-May-12 2:53am
v2
Comments
Maciej Los 11-May-12 8:53am    
Code tags added

Please rename: @Id to @ID

Happy ....ending

Morgs
 
Share this answer
 
hi Fanjolama,

I think you are calling worng stored procedure. Please check the below two lines and will conform both are same or not.


1) SqlDataAdapter sda = new SqlDataAdapter("uuspGetAllMprOneById", con);
2)
SQL
alter PROCEDURE [dbo].[uuspGetAllById]


In friest one you are calling "uuspGetAllMprOneById" but your stored procedure name is uuspGetAllById

So please check it.. once it check let me know this is correct or not.

Regards,
venkat panepalli
 
Share this answer
 
SQL
alter PROCEDURE [dbo].[uuspGetAllById]
    @Id uniqueidentifier
AS
SET NOCOUNT ON
Select * from mUsers where DId=@Id

return
 
Share this answer
 
Have you tried setting the command type:
C#
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
 
Share this answer
 
hi penepallivenkat

my stored procedure name is : uuspGetAllById..
Problem still exist....

But i sloved it...

C#
public DataTable GetAllById(string Did)
   {
       DataTable tableMpr=null;
       con.Open();
       DataSet ds = new DataSet();
       cmd = new SqlCommand("uuspGetAllById", con);
       cmd.CommandType = CommandType.StoredProcedure;
       cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = Did.ToString();
       sda = new SqlDataAdapter(cmd);
       sda.Fill(ds);
       con.Close();
       tableMpr = ds.Tables[0];
       return tableMpr;
   }
 
Share this answer
 
v2
Comments
Morgs Morgan 11-May-12 7:58am    
Say ThankYou when people help incase you need help soon so we can consider helping you again, just how it normally goes.
Fanjolama 12-May-12 4:33am    
i already say thank to everyone in advance....
Again thanks you..
Maciej Los 11-May-12 8:54am    
This is not an answer. Please move some part into comment and remove the 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