public double FindSubTotal()
{
SqlConnection objConnection;
SqlCommand objCommand;
string SQL, s;
double price;
objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["WebsiteAdminConnectionString"].ConnectionString);
objConnection.Open();
s = "";
price = 0.0;
//SQL = "SELECT isnull(balance, 0) as balance FROM PurchaseList where productType=3 AND userID =" + Request.Cookies["customerID"].Value + " ";
SQL = "SELECT ISNULL(price, 0) as p FROM tempList where userID=" + Request.Cookies["customerID"].Value;
objCommand = new SqlCommand(SQL, objConnection);
objCommand.Prepare();
SqlDataReader objDataReader = objCommand.ExecuteReader();
if (objDataReader.HasRows)
{
while (objDataReader.Read() == true)
{
price = price + Convert.ToDouble(objDataReader["p"]);
}
}
objConnection.Close();
return price;
}
public string FindDesc()
{
SqlConnection objConnection;
SqlCommand objCommand;
string SQL, s, items;
double price;
objConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["WebsiteAdminConnectionString"].ConnectionString);
objConnection.Open();
s = "";
price = 0.0;
if (Request.Cookies["mycookie"] == null) return "0"; // I added this to remove the cookies and page loads up.
//SQL = "SELECT isnull(balance, 0) as balance FROM PurchaseList where productType=3 AND userID =" + Request.Cookies["customerID"].Value + " ";
SQL = "SELECT ISNULL(price, 0) as p, quantity, productName FROM tempList where userID=" + Request.Cookies["customerID"].Value;
objCommand = new SqlCommand(SQL, objConnection);
objCommand.Prepare();
SqlDataReader objDataReader = objCommand.ExecuteReader();
items = "";
if (objDataReader.HasRows)
{
while (objDataReader.Read() == true)
{
price = Convert.ToDouble(objDataReader["p"]);
items = items + " DESC: " + Convert.ToString(objDataReader["productName"]).Replace("'","").Replace(@"""","").Replace(@"™","") + " QTY: " + Convert.ToString(objDataReader["quantity"]) + " $" + price.ToString("N");
}
}
objConnection.Close();
return items;
}
This a page - viewbasket.aspx.cs .when i click on viewbasket button it showed error ,found out this is due to a null
value passed to cookie and used the code -mentioned "to remove cookies" trying to clear it. now i am experiencing an issue because request.cookies is empty and unable to add items to cart as string is getting emptied.
Unique ID has been set already "customerID" for cookies. Please help me with this anyone, I am not familiar with asp.net. But just need a fix with this. Thanks in advance my friends