Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
Globali GB17=new Globali();

public DataSet Selectall(int id)
{
    //Create and open new sql connection
    SqlConnection Gconn = new SqlConnection(GB17.autocreateconn());
    Gconn.Open();
    string Gstname = "GroupSelect_All";
    SqlCommand Gcomand1 = new SqlCommand(Gstname, Gconn);
    Gcomand1.CommandType = CommandType.StoredProcedure;
    Gcomand1.Parameters.Add("@id", SqlDbType.Int).Value = id;
    SqlDataAdapter Gda = new SqlDataAdapter(Gstname, Gconn);
    DataSet Gds = new DataSet();
            
    Gda.Fill(Gds, "lms_group");
            
    return Gds;
    //connection closed
    Gconn.Close();
  }


all things are correct wat i dont understand why exception comes
the exception is
"Procedure or Function 'GroupSelect_All' expects parameter '@id', which was not supplied."

stored procedure is executed correctly and during debugging value also passed of parameter
but exception arises
Posted
Updated 20-Apr-10 0:11am
v2

1 solution

Change
SqlDataAdapter Gda = new SqlDataAdapter(Gstname, Gconn);
To
SqlDataAdapter Gda = new SqlDataAdapter(Gcomand1);
should do the trick.
 
Share this answer
 
Comments
shefeekcm 15-Mar-11 8:41am    
good

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