HI, i am currently working on a project, when i run the program, there is an error showing on button click event It says this:
Exception Details: System.IndexOutOfRangeException: There is no row at position 0.
- protected void btnAddCart_Click(object sender, EventArgs e)
- {
- if (Session["Mycart"] == null)
- {
- ShoppingCart Mycart = new ShoppingCart();
- Session["Mycart"] = Mycart;
- }
- string Id = Request.QueryString["BookID"];
- Mycart =(ShoppingCart)Session["New"];
- String Query = "select * from BookData where BookID= '" + Id + "'";
- SqlCommand cmd = new SqlCommand(Query, con);
- SqlDataAdapter Da = new SqlDataAdapter(cmd);
- DataTable Dt = new DataTable();
- Da.Fill(Dt);
- DataRow row = Dt.Rows[0];
- Mycart.Insert(new CartItem(Int32.Parse(Id),
- row["name"].ToString(),
- row["author"].ToString(),
- int.Parse(row["isbn"].ToString()),
- row["language"].ToString(),
- row["publisher"].ToString(),
- row["Summary"].ToString(),
- Double.Parse(row["price"].ToString()),
- 1)
- );
- }
Please reply fast, its very urgent
thank you.