Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have to send request to user,bt this code doesnt work.
somebody plz help me to pointing me out to my mistake..
in this code at the 2nd if condition session values has change to the recenty login user..
dont knw how can be it possible..
on any user's profile page it shows the message " your own profile"..

C#
protected void AddToFriend_Click(object sender, EventArgs e)
        {
            if (!object.Equals(Session["UserId"], null))
            {
              if (Session["UserId"].ToString() !="")
                {
                    lblError.Text = "Your own profile";
                    lblError.Visible = true;
                }
                else
                {
                    string chkfriendRequest = "SELECT * FROM Friend WHERE (myid='" + Session["UserId"].ToString() + "' and frandid='" +  Convert.ToInt32(Request.QueryString["id"])+ "') OR (myid='" +  Convert.ToInt32(Request.QueryString["id"]) + "' and frandid='" + Session["UserId"].ToString() + "')";
                    DataTable dt1 = new DataTable();
                    dt1 = dbClass.ConnectDataBaseReturnDT(chkfriendRequest);
                    if (dt1.Rows.Count > 0)
                    {
                        if (dt1.Rows[0]["FriendStatus"].ToString() == "1")
                        {
                            lblError.Text = "Already in friend list";
                            lblError.Visible = true;
                        }
                        if (dt1.Rows[0]["FriendStatus"].ToString() == "0")
                        {
                            lblError.Text = "Friend Request Pending";
                            lblError.Visible = true;
                        }
                        if (dt1.Rows[0]["FriendStatus"].ToString() == "2")
                        {
                            lblError.Text = "Friend Request deny";
                            lblError.Visible = true;
                        }
                    }
                    else
                    {
                        string friendRequest = "Insert INTO Friend (myid,frandid) VALUES('" + Session["UserId"].ToString() + "','" +  Convert.ToInt32(Request.QueryString["id"]) + "')";
                        dbClass.ConnectDataBaseToInsert(friendRequest);
                        lblError.Text = "Friend Request Send";
                        lblError.Visible = true;
                    }
                }
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }

        }
Posted
Comments
[no name] 19-Apr-13 13:31pm    
"bt this code doesnt work" mean absolutely nothing to anyone but you. How are we to know what "doesn't work" means? Does the code not run at all? Does the code run but does something weird? Does the code throw any errors? Did the code make your house burn down?
mahi0607 19-Apr-13 13:36pm    
ye this code run, there is no error on it.. i m enable to send request to user... it's just showing message that "your own profile" on evry user's page..

is there any mistake done by me..?
plz suggest me.
ZurdoDev 19-Apr-13 14:23pm    
You need to reply to the comment so that the person who made the comment is notified. Instead you just added a comment to your own question.

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