aditya immadi

aditya immadi

  • NA
  • 205
  • 71.7k

expect parameter @id which was not suppled

Sep 25 2013 10:20 AM
Hai all,
        when i'm tying to develop the unlimited scrolling for my datalist i'm acing small problem can any one help me

  if (Session["id"] != null)
            {
                mydb db = new mydb();
                //Fetch 14 records initially.
                DataSet dsProducts = db.GetProducts();
                //Bind data to gridview
                dl.DataSource = dsProducts;
                dl.DataBind();
            }

        }
        protected void btnGetMoreRecords_Click(object sender, EventArgs e)
        {
            mydb db = new mydb();
            //Fetch 14 records initially.
            DataSet dsProducts = db.FetchNextProducts(Convert.ToInt32(hiddenLastProductID.Value), 14);
            //Bind data to gridview
            dl.DataSource = dsProducts;
            dl.DataBind();

error:expect parameter @id which was not suppled


        }

        public class mydb
        {
            private SqlConnection con;
            public mydb()
            {
                con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
            }

            public DataSet GetProducts()
           
            {

                SqlCommand cmd = new SqlCommand("select top 5 decription,url from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id where tb_userlogin.id=@id", con);
                    cmd.Parameters.AddWithValue("@id", id);
                    
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    return ds;
error:expect parameter @id which was not suppled 
            }

            public DataSet FetchNextProducts(int productId, int recordsCount)
            {
                DataSet ds = new DataSet();
                string query = string.Format("select top {0} * from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id where tb_userlogin.id=@id ASC", recordsCount, productId);
                SqlCommand cmd = new SqlCommand(query, con);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(ds);
                return ds;
            }


Thanks and Regards

Answers (1)